带有多个atachement的php邮件
我想使用php基本库发送一封包含两个atachement的邮件 到目前为止,我使用这个带有多个atachement的php邮件,php,Php,我想使用php基本库发送一封包含两个atachement的邮件 到目前为止,我使用这个 while($donnee = $reponse->fetch()){ $mime_boundary = md5(uniqid(time())); $message = "message text"; $to = $donnee["MAIL"]; //define the subject of the email $subject = "title";; //create a boundary
while($donnee = $reponse->fetch()){
$mime_boundary = md5(uniqid(time()));
$message = "message text";
$to = $donnee["MAIL"];
//define the subject of the email
$subject = "title";;
//create a boundary string. It must be unique
//so we use the MD5 algorithm to generate a random hash
$random_hash = md5(date('r', time()));
// from
$header = "From : sender-mail \r\nReply-To: sender-mail \r\n";
$header .= "MIME-Version:1.0\r\n";
$header .= "Content-Type:multipart/mixed; boundary=\"{$mime_boundary}\"\r\n\r\n";
// message
$header .= "--{$mime_boundary}\r\n";
$header .= "Content-Type:text/html; charset=\"ISO-8859-1\"\r\n";
$header .= "Content-Transfer-Encoding:7bit\r\n\r\n";
$header .= "<html><head><style type=\"text/css\">body { font:10pt Arial; }</style></head><body>". str_replace("\r", "", str_replace("\n", "<br />", $message)) ."</body></html>\r\n\r\n";
// attachment
$attachments = array("../fichier/downloadable/cv.docx","../fichier/downloadable/resume.pdf");
$attachmentNames = array("Covering_Letter_Anthony_Pifarré.docx","CV_Anthony_Pifarré.pdf");
for ($i = 0; $i < count($attachments); $i++)
{
if (!base64_decode($attachments[$i], true))
$attachments[$i] = base64_encode($attachments[$i]);
else
$attachments[$i] = str_replace("\r", "", str_replace("\n", "", str_replace(" ", "+", $attachments[$i])));
$header .= "--{$mime_boundary}\r\n";
$header .= "Content-Type:application/octet-stream; name=\"{$attachmentNames[$i]}\"\r\n";
$header .= "Content-Transfer-Encoding:binary\r\n";
$header .= "Content-Disposition:attachment; filename=\"{$attachmentNames[$i]}\"\r\n";
$header .= "{$attachments[$i]}\r\n\r\n";
}
//send the email
mail( $to, $subject, "", $header );
$requ = 'UPDATE mailing_list SET ALREADY_SENT = 1 WHERE ID = "'.$donnee["ID"].'"';
//$bdd->exec($requ);
echo "<br/>"."Sent To : ".$donnee["MAIL"];
$counter++;}
while($donnee=$reponse->fetch()){
$mime_boundary=md5(uniqid(time());
$message=“消息文本”;
$to=$donnee[“邮件”];
//定义电子邮件的主题
$subject=“title”;;
//创建边界字符串。它必须是唯一的
//所以我们使用MD5算法来生成一个随机散列
$random_hash=md5(日期('r',时间());
//从
$header=“From:sender-mail\r\n提交至:sender-mail\r\n”;
$header.=“MIME版本:1.0\r\n”;
$header.=“内容类型:多部分/混合;边界=\”{$mime\U边界}\“\r\n\r\n”;
//信息
$header.=“--{$mime\U边界}\r\n”;
$header.=“内容类型:text/html;字符集=\”ISO-8859-1\“\r\n”;
$header.=“内容传输编码:7bit\r\n\r\n”;
$header.=“body{font:10pt Arial;}”.str_replace(“\r”,”,str_replace(“\n”,“
,$message))。“\r\n\r\n”;
//附件:
$attachments=array(“../fichier/downloadable/cv.docx”,”。/fichier/downloadable/resume.pdf”);
$attachmentNames=数组(“封面字母”Anthony_Pifarré.docx,“CV_Anthony_Pifarré.pdf”);
对于($i=0;$iexec($requ);
echo“
”发送至:“..donnee[“邮件”];
$counter++;}
这给我一个正确的文字信息电子邮件,与良好的发件人联合国名称是确定的。
但是数据表是空的。我有两个文件,名字正确,但重量为0。
当我试图写$attachements[$i]ig时,我得到了一些文本,而不是什么都没有
有什么想法吗?用PHPMailer代替PHP的
mail
功能。更好的错误报告和很多可能性。这可能会帮助您感谢Vahe,这是我正在寻找的代码类型,因为我不确定我是否可以在我的主机(即legtux)上安装类似phpMail的LIB。