我正在用phpmailer
發送附件的電子郵件。從未收到附件的PHPMailer
include_once('/home/site/PHPMailer/class.phpmailer.php');
$mail = new PHPMailer();
$body = $mail->getFile('contents.html');
$body = eregi_replace("[\]",'',$body);
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "smtp.free.fr"; // SMTP server
$mail->IsSendmail(); // telling the class to use SendMail transport
$mail->From = "[email protected]";
$mail->FromName = "name";
$mail->Subject = "subject";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$mail->AddAddress("[email protected]", "name");
$mail->AddAttachment("mylist.csv"); // attachment
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
我收到「發送的消息!」在執行,但沒有收到電子郵件。
查看您的系統日誌或/ var/mail /用戶名,以查看是否收到任何錯誤或反彈。 – 2012-08-16 13:54:55
我不確定你想要在設置中完成什麼。您首先指定使用SMTP,然後切換到Sendmail。你想使用哪種運輸工具? – 2012-08-16 13:54:59
檢查您的垃圾郵件文件夾。如果標題設置不正確,電子郵件服務器有將自動電子郵件解釋爲垃圾郵件的習慣。 – Matt 2012-08-16 13:57:09