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.
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥50 potsgresql15备份问题
- ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
- ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
- ¥60 pb数据库修改与连接
- ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
- ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
- ¥20 神经网络Sequential name=sequential, built=False
- ¥16 Qphython 用xlrd读取excel报错
- ¥15 单片机学习顺序问题!!
- ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上