I have an issue: i need to create csv file and send it attached to the particular emails. Honestly i never do that so i'm quite a lammer in this matter. Can anybody tell me with what i have to start or share some links?
1条回答 默认 最新
- dqtm8504 2011-04-28 09:27关注
I think this what you are looking for, i've used it in the past works perfectly.
Hope it helps.
<?php $cr = " "; $csvdata = "First Name" . ',' . "Last Name" . $cr; $csvdata .= $txtFName . ',' . $txtLName . $cr; $thisfile = 'file.csv'; $encoded = chunk_split(base64_encode($csvdata)); // create the email and send it off $subject = "File you requested from RRWH.com"; $from = "scripts@rrwh.com"; $headers = 'MIME-Version: 1.0' . " "; $headers .= 'Content-Type: multipart/mixed; boundary="----=_NextPart_001_0011_1234ABCD.4321FDAC"' . " "; $message = ' This is a multi-part message in MIME format. ------=_NextPart_001_0011_1234ABCD.4321FDAC Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hello We have attached for you the PHP script that you requested from http://rrwh.com/scripts.php as a zip file. Regards ------=_NextPart_001_0011_1234ABCD.4321FDAC Content-Type: application/octet-stream; name="'; $message .= "$thisfile"; $message .= '" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="'; $message .= "$thisfile"; $message .= '" '; $message .= "$encoded"; $message .= ' ------=_NextPart_001_0011_1234ABCD.4321FDAC-- '; // now send the email mail($email, $subject, $message, $headers, "-f$from"); ?>
Kind regards, Wesley.
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥17 pro*C预编译“闪回查询”报错SCN不能识别
- ¥15 微信会员卡接入微信支付商户号收款
- ¥15 如何获取烟草零售终端数据
- ¥15 数学建模招标中位数问题
- ¥15 phython路径名过长报错 不知道什么问题
- ¥15 深度学习中模型转换该怎么实现
- ¥15 HLs设计手写数字识别程序编译通不过
- ¥15 Stata外部命令安装问题求帮助!
- ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
- ¥15 TYPCE母转母,插入认方向