SMTP电子邮件不发送
问题描述:
我试图通过smtp发送电子邮件,但不幸的是,它没有被发送。似乎没有错误。我哪里有错误?SMTP电子邮件不发送
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // send via SMTP
$mail->Host = "mail.site.org"; // SMTP servers
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "[email protected]"; // SMTP username
$mail->Password = "123456"; // SMTP password
$mail->From = "[email protected]"; // smtp kullanıcı adınız ile aynı olmalı
$mail->Fromname = "giden ismi";
$mail->AddAddress("[email protected]","Ornek Isim");
$mail->Subject = $_POST['baslik'];
$mail->Body = implode(" ",$_POST);
if(!$mail->Send())
{
echo "Mail couldnt send <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Mail sent";
答
试试这个,让错误:
当你运行它require("class.phpmailer.php");
$mail = new PHPMailer(true);
try {
$mail->IsSMTP(); // send via SMTP
$mail->Host = "mail.site.org"; // SMTP servers
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "[email protected]"; // SMTP username
$mail->Password = "123456"; // SMTP password
$mail->From = "[email protected]"; // smtp kullanıcı adınız ile aynı olmalı
$mail->Fromname = "giden ismi";
$mail->AddAddress("[email protected]","Ornek Isim");
$mail->Subject = $_POST['baslik'];
$mail->Body = implode(" ",$_POST);
$mail->Send();
echo "Message Sent OK\n";
}
catch (phpmailerException $e) {
echo $e->errorMessage();
}
catch (Exception $e) {
echo $e->getMessage();
}
+0
感谢您的帮助。发送这个之后,我收到了“消息发送”报告。但不要邮寄到我的邮箱。 – bodrumlife 2014-11-09 01:03:55
+0
什么都出现在你的SMTP日志中? – EdvinasJ 2014-11-09 12:36:25
那么什么是输出?你看到'Mail couldnt send'消息或'Mail sent'消息吗? – Jordan 2014-11-08 23:31:43
你有SMTP服务器吗?日志里有什么? – andrewsi 2014-11-08 23:54:55
是的,我有Smtp服务器。我在网上使用检查脚本检查它。问题是发送邮件后。我收到“消息发送”报告,但我没有收到邮件。 – bodrumlife 2014-11-09 01:02:07