我使用phpmailer()概念使用php脚本从共享服务器向用户发送邮件,但根据phpmailer代码,即使脚本中的所有内容都正确,我也无法发送邮件。
我的代码如下:
$message = " This is testing message from my server";
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->Host = "smtp.gmail.com";
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Port = 465; // or 587
$mail->IsHTML(true);
$mail->Username = "moorthi.mrk10@gmail.com"; // My gmail username
$mail->Password = "************"; // My Gmail Password
$mail->SetFrom("moorthi.mrk10@gmail.com");
$mail->Subject = "Test Mail from my Server";
$mail->Body = $message;
$mail->AddAddress($email);
if($mail->Send())
{
print json_encode("SUCCESS");
}
else
{
echo "Mailer Error: " . $mail->ErrorInfo;
}注意:我使用“GMail”作为服务器,SMTPSecure为“ssl”,端口为"465“,用户名和密码为GMail用户名和密码。
我使用了VPS共享服务器,并在该服务器上保留了我的php脚本。
我认为我的php脚本没有问题,我不知道为什么它不能工作。
,我得到了这样的错误。
2014-02-21 12:30:11 CLIENT -> SERVER: EHLO jkcorporates.com
2014-02-21 12:30:11 CLIENT -> SERVER: AUTH LOGIN
2014-02-21 12:30:11 CLIENT -> SERVER: bW9vcnRoaS5tcmsxMEBnbWFpbC5jb20=
2014-02-21 12:30:11 CLIENT -> SERVER: OTk0MTI0MTE0MA==
2014-02-21 12:30:11 SMTP ERROR: Password command failed: 534-5.7.14
534-5.7.14 i-_eumA> Please log in via your web browser and then try again.
534 5.7.14 54 k76sm17979938yho.18 - gsmtp
2014-02-21 12:30:11 CLIENT -> SERVER: QUIT
" The ERROR is " SMTP connect() failed.请给出一些解决办法。
提前谢谢。
记住:我使用共享服务器名'VPS.mydomain.com‘,我想使用GMail作为我的SMTP服务器向用户发送邮件。
发布于 2018-12-17 10:39:42
除非您完成g-mail帐户的两步验证并使用该密码,否则您的邮件将不会在线发送。
https://stackoverflow.com/questions/21937586
复制相似问题