[英]phpmailer not sending email
i am using phpmailer and i am getting following error: 我正在使用phpmailer,我收到以下错误:
Message was not sent Mailer Error: SMTP Error: Could not connect to SMTP host. 邮件未发送邮件程序错误:SMTP错误:无法连接到SMTP主机。
<?php
require("class.phpmailer.php");
$mailer = new PHPMailer();
$mailer->IsSMTP();
$mailer->Host = 'ssl://smtp.myhost.com:465';
$mailer->SMTPAuth = TRUE;
$mailer->Username = 'myemail@myhost.com';
$mailer->Password = 'mypass';
$mailer->From = 'myemailagain@myhost.com';
$mailer->FromName = 'myname';
$email1 = $_GET['email'];
$verification = rand();
$mailer->Body = 'Welcome to our site';
$mailer->Subject = 'verification';
$mailer->AddAddress($email1);
if(!$mailer->Send())
{
echo "Message was not sent<br/ >";
echo "Mailer Error: " . $mailer->ErrorInfo;
}
else
{
echo "Message has been sent";
}
?>
note: i use "myhost.com" but it's not my real domain 注意:我使用“myhost.com”,但这不是我的真实域名
I believe you are specifying your host incorrectly. 我相信你错误地指定了你的主机。 Try this instead: 试试这个:
$mailer->Host="smtp.myhost.com";
$mailer->Port=465;
$mailer->SMTPSecure="ssl"; //If this doesn't work, try 'tls'
If it still doesn't work, consider setting: 如果仍然无效,请考虑设置:
$mailer->SMTPDebug=1;
Also, make sure PHP's OpenSSL extension is enabled. 此外,请确保启用PHP的OpenSSL扩展。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.