1
我試圖通過PHP發送電子郵件,並且在郵件傳遞時,我遇到了一個小問題。在Gmail中,可能還有其他電子郵件客戶端,郵件的最後一行(簽名)正在被截斷。通過「剪輯」我的意思是最後一行是隱藏的,有一個按鈕可以點擊取消隱藏最後一行。如何發送簽名未被剪輯的HTML電子郵件?
有什麼方法可以阻止這種情況發生?這是我第一次嘗試通過PHP發送HTML電子郵件,所以我想也許有某種我不知道的語法。
我基本上只是使用PHPMailer的示例代碼:
require_once('../class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
$mail->IsSMTP(); // telling the class to use SMTP
try {
$mail->Host = "mail.yourdomain.com"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "tls"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 587; // set the SMTP port for the GMAIL server
$mail->Username = "[email protected]"; // GMAIL username
$mail->Password = "yourpassword"; // GMAIL password
$mail->AddReplyTo('[email protected]', 'First Last');
$mail->AddAddress('[email protected]', 'John Doe');
$mail->SetFrom('[email protected]', 'First Last');
$mail->AddReplyTo('[email protected]', 'First Last');
$mail->Subject = 'PHPMailer Test Subject via mail(), advanced';
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
$mail->MsgHTML(file_get_contents('contents.html'));
$mail->AddAttachment('images/phpmailer.gif'); // attachment
$mail->AddAttachment('images/phpmailer_mini.gif'); // attachment
$mail->Send();
echo "Message Sent OK<p></p>\n";
} catch (phpmailerException $e) {
echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
echo $e->getMessage(); //Boring error messages from anything else!
}
感謝你的建議。
顯示您正在使用的代碼以及您看到的「裁剪」示例 – 2012-07-14 20:40:43
我正在使用phpmailer示例代碼,但我會發布它。 – Nate 2012-07-14 20:41:39
'contents.html'裏有什麼? – 2012-07-14 20:45:25