我正在使用 TCPDF 创建配置文件并将配置文件作为附件发送。我有许多客户使用该软件,并且需要批量电子邮件服务。
我一直在从本地服务器电子邮件发送配置文件,它工作得很好。
这是以前的代码(只是电子邮件部分):
$pdf->writeHTML($tbl, true, false, false, false, '');
$js .= 'print(true);';
// set javascript
$pdf->IncludeJS($js);
//Close and output PDF document
//Close and output PDF document
//define the receiver of the email
$to = $Email;
$subject = "Profile";
$repEmail = 'me@mydomain.com';
$fileName = 'Profile.pdf';
$fileatt = $pdf->Output($fileName, 'S');
$attachment = chunk_split(base64_encode($fileatt));
$eol = PHP_EOL;
$separator = md5(time());
$headers = 'From: Identykidz <'.$repEmail.'>'.$eol;
$headers .= 'MIME-Version: 1.0' .$eol;
$headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\"";
$message = "--".$separator.$eol;
$message .= "Content-Transfer-Encoding: 7bit".$eol.$eol;
$message .= "Dear parent/guardian \r\n\r\nPlease find attached the Profile attached.Kind regards\r\nIdentyKidz Information Centre".$eol;
$message .= "--".$separator.$eol;
$message .= "Content-Type: text/html; charset=\"iso-8859-1\"".$eol;
$message .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
$message .= "--".$separator.$eol;
$message .= "Content-Type: application/pdf; name=\"".$fileName."\"".$eol;
$message .= "Content-Transfer-Encoding: base64".$eol;
$message .= "Content-Disposition: attachment".$eol.$eol;
$message .= $attachment.$eol;
$message .= "--".$separator."--";
// Send the email
if(mail($to, $subject, $message, $headers)) {
echo '<span style="color:#1e73be; text-align: center; font-family: Verdana">The profile has been sent successfully to the email address entered.</span>';
}
else {
echo "There was an error sending the mail.";
}
}
//catch exception
catch(Exception $e) {
header("Location: something_went_wrong.php");
}
//============================================================+
// END OF FILE
//============================================================+
因为我需要使用批量电子邮件服务,所以我必须包括批量电子邮件服务提供商的SMTP详细信息,所以我将TCPDF的电子邮件部分从mail()更改为PHPMailer。
潇潇雨雨
紫衣仙女
元芳怎么了
忽然笑