我正面临在我的网站上应用PHP邮件的问题,目前正在使用。我使用katyaweb.com进行网站托管。 我在运行WAMP的本地计算机上配置并测试了PHP邮件程序。 它在我的本地主机上工作得很好,消息可以成功发送,接收者也可以收到消息。
但是当我将它应用到我的网站' projectmedussa.com'时,它会产生很大的错误。我不知道为什么?如果有人能帮助我,我将非常感激。
谢谢,
这是我的代码。
<?php
require 'smptmail/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'medusa123.test@gmail.com'; // SMTP username
$mail->Password = '*******'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
$mail->setFrom('medusa123.test@gmail.com', 'Medusa');
//$mail->addAddress('joe@example.net', 'Joe User'); // Add a recipient
$mail->addAddress('mahdi2.samim@gmail.com'); // Name is optional
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'You successfully registered to medusa website';
$mail->Body = 'this is testing message from meudusa123.test@gmail.com';
$mail->AltBody = 'This is to test whether the phpmailer work or not!';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
?>
我收到以下错误
2017-03-25 07:42:22 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP
10sm5875220wrz.44 - gsmtp 2017-03-25 07:42:22 CLIENT -> SERVER: EHLO
projectmedussa.com 2017-03-25 07:42:22 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [91.148.168.54] 250-SIZE 35882577 250-8BITMIME
250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH 250-
ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8 2017-03-25 07:42:22
CLIENT -> SERVER: AUTH LOGIN 2017-03-25 07:42:23 SERVER -> CLIENT: 334
VXNlcm5hbWU6 2017-03-25 07:42:23 CLIENT -> SERVER:
bWVkdXNhMTIzLnRlc3RAZ21haWwuY29t 2017-03-25 07:42:23 SERVER -> CLIENT: 334
UGFzc3dvcmQ6 2017-03-25 07:42:23 CLIENT -> SERVER: bWVkdXNhMTIzNDU= 2017-03-25
07:42:23 SERVER -> CLIENT: 534-5.7.14 Please log in via your web browser and
534-5.7.14 then try again. 534-5.7.14 Learn more at 534 5.7.14
https://support.google.com/mail/answer/78754 10sm5875220wrz.44 - gsmtp 2017- 03-
25 07:42:23 SMTP ERROR: Password command failed: 534-5.7.14 Please log in via
your web browser and 534-5.7.14 then try again. 534-5.7.14 Learn more at 534
5.7.14 https://support.google.com/mail/answer/78754 10sm5875220wrz.44 - gsmtp
2017-03-25 07:42:23 SMTP Error: Could not authenticate. 2017-03-25 07:42:23
CLIENT -> SERVER: QUIT 2017-03-25 07:42:23 SERVER -> CLIENT: 221 2.0.0 closing
connection 10sm5875220wrz.44 - gsmtp 2017-03-25 07:42:23 SMTP connect() failed.
https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Message could not be
sent.Mailer Error: SMTP connect() failed.
https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting