發郵件的問題,有做過的請進!
第一種:
$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