我有一個問題:我需要創建CSV文件,並將其附加到特定的電子郵件。 老實說,我從來沒有這樣做,所以我在這件事上相當沉重。任何人都可以告訴我,我必須開始或分享一些鏈接?發送CSV文件附加到電子郵件
4
A
回答
18
我認爲這是你正在尋找的東西,我用它在過去完美的作品。
希望它有幫助。
<?php
$cr = "\n";
$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 = "[email protected]";
$headers = 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-Type: multipart/mixed;
boundary="----=_NextPart_001_0011_1234ABCD.4321FDAC"' . "\n";
$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");
?>
親切的問候, 韋斯利。
相關問題
- 1. 發送HTML電子郵件 - 如何將.html文件附加到電子郵件?
- 2. 用附件發送電子郵件到多封電子郵件
- 3. 的Robocopy發送電子郵件,附件,附加文件名
- 4. PHP發送電子郵件與文件附件 - 電子郵件不發送
- 5. 將.png文件附加到由satchmo發送的電子郵件
- 6. Java:發送電子郵件附件:無法發送附件
- 7. SendGrid電子郵件API,發送電子郵件附件
- 8. 將文件附加到電子郵件
- 9. Android電子郵件發送無附件
- 10. 發送電子郵件附件C#
- 11. Flex&PHP - 發送電子郵件附件
- 12. 發送帶附件的電子郵件
- 13. 發送電子郵件附件
- 14. 發送電子郵件和附件
- 15. ASP.NET MVC發送電子郵件附件
- 16. php發送電子郵件附件
- 17. 發送帶附件的電子郵件
- 18. 發送電子郵件附件
- 19. 發送電子郵件與wordpress附件
- 20. WP7.1發送電子郵件附件
- 21. PHP電子郵件PDF附件發送
- 22. 發送電子郵件與pdf附件
- 23. 發送電子郵件附件收到空白文件
- 24. 將電子郵件附件發送到本地文件夾
- 25. 如何附加CSV文件使用山魈發送電子郵件?
- 26. 將csv文件附加到django中的電子郵件
- 27. 試圖發送csv作爲C#中的電子郵件附件#
- 28. 發送電子郵件與Django中附加文件
- 29. 附加文件與工作表通過電子郵件發送
- 30. 附加文件通過電子郵件發送通過EXCEL
你堅持什麼方面?你有什麼代碼? – 2011-04-28 09:25:17