發郵件的有關問題,有做過的請進

來源:互聯網
上載者:User
發郵件的問題,有做過的請進!
第一種:
$to = "[email protected]";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "[email protected]";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";

===================================
第二種


require 'class.phpmailer.php';

try {
$mail = new PHPMailer(true); //New instance, with exceptions enabled

$body = file_get_contents('contents.html');
$body = preg_replace('/\\\\/','', $body); //Strip backslashes

$mail->IsSMTP(); // tell the class to use SMTP
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Port = 25; // set the SMTP server port
$mail->Host = "smtp.126.com"; // SMTP server
$mail->Username = "[email protected]"; // SMTP server username
$mail->Password = "luo11111"; // SMTP server password

$mail->IsSendmail(); // tell the class to use Sendmail

$mail->AddReplyTo("[email protected]","First Last");

$mail->From = "[email protected]";
$mail->FromName = "比翼網";

$to = "[email protected]";

$mail->AddAddress($to);

$mail->Subject = "First PHPMailer Message";

$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->WordWrap = 80; // set word wrap

$mail->MsgHTML($body);

$mail->IsHTML(true); // send as HTML

if(!$mail->Send())
{
echo "Message could not be sent.

";
echo "Mailer Error: " . $mail->ErrorInfo;
exit();
} else {
echo "Message has been sent";
}
} catch (phpmailerException $e) {
echo $e->errorMessage();
}

啟動sendmail後,發出的郵件在垃圾郵件裡?

=====================================================================


------解決方案--------------------
sendmail成功後,要用接收程式才能接收到,我機子上的是qmail,你的就不知道了。
------解決方案--------------------
啟動sendmail後,發出的郵件在垃圾郵件裡?

有可能是內送郵件的郵箱有相關的過濾設定,這些設定
可能是使用者自己定義好的,也可能是郵箱預設就定義好
的。造成的結果就是:當某一類郵件或者某個使用者的郵
件發送到目標郵箱後,目標郵箱自動識別其為垃圾郵件,
並將其刪除或者放在資源回收筒中,這樣你看到的當然就是
垃圾郵件了,
------解決方案--------------------
第一種肯定不好, 你自己sendmail做smtp伺服器不會被其他郵件伺服器信任,用126的做smtp肯定不容易被認為垃圾郵件了。
------解決方案--------------------
$mail->IsSendmail(); // tell the class to use Sendmail

這句去掉。
------解決方案--------------------
垃圾郵件沒法控制
------解決方案--------------------
更換IP

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.