Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/248.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带有多个atachement的php邮件_Php - Fatal编程技术网

带有多个atachement的php邮件

带有多个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

我想使用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 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;$i