0
我使用PHPMailer自動發送訂單確認作爲HTML格式的電子郵件。除了確認格式不正確之外,所有內容都按預期工作。我在我的樣式表中加入了一個'AddAttachment'這一行,它似乎固定了確認表單的標題,但是表單的其餘部分仍然不正確。有沒有人遇到過這種情況,並知道我需要做什麼來解決它?我編輯的程序代碼如下,以防萬一它會幫助!PHPMailer和樣式表格式化
<?php
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->SMTPDebug = 0;
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPAuth = true;
$mail->Port = 25; // set the SMTP port
$mail->Host = "<<smtp server>>"; // SMTP server
$mail->Username = "<<username>>";
$mail->Password = "<<password>>";
$mail->From = "<<email address>>";
$mail->FromName = "<<name>>";
$mail->AddAddress("<<email address>>");
$mail->Subject = "Acknowledgement Form";
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
$mail->IsHTML(true);
$mail->Body = file_get_contents('<<acknowledgement form page>>');
$mail->AddAttachment('printer.css'); // attach style sheet
if(!$mail->Send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent.';
}
?>