当我使用自己的电子邮件地址时,我的电子邮件正在运行,但我需要使用网站新创建的电子邮件来运行此电子邮件。此电子邮件是使用gmail创建的。
这是我的代码:
function phpMailer($emailTo, $subject, $body)
{
$email_temp = $body;
$to = $emailTo;
Yii::import('application.extensions.phpmailer.JPhpMailer');
$mail = new JPhpMailer;
$mail->IsSMTP();
//$mail->Host = 'smtp.googlemail.com:465';
$mail->Host = 'smtp.gmail.com';
$mail->SMTPSecure = "tls";
$mail->Port = 587;//465;
$mail->SMTPAuth = true;
$mail->SMTPDebug = true;
$mail->Username = 'info@domainname.com';
$mail->Password = 'xxxxxxxx';
$mail->SetFrom('info@domainname.com', 'domainname'); //Send 'From' User
$mail->Subject = $subject;
$mail->AltBody = $email_temp;
$mail->MsgHTML($email_temp); // message /template
$mail->AddAddress($to); //Send mail 'To' User
//check if mail sent successfully
if($mail->Send())
return true;
return false;
}
使用代码2进行调试时,我得到了以下响应。
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "220 smtp.gmail.com ESMTP c3sm6277150qge.12 - gsmtp "
SMTP -> get_lines(): $data is "220 smtp.gmail.com ESMTP c3sm6277150qge.12 - gsmtp "
SMTP -> FROM SERVER:220 smtp.gmail.com ESMTP c3sm6277150qge.12 - gsmtp
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "250-smtp.gmail.com at your service, [54.209.41.153] "
SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [54.209.41.153] "
SMTP -> get_lines(): $data was "250-smtp.gmail.com at your service, [54.209.41.153] "
SMTP -> get_lines(): $str is "250-SIZE 35882577 "
SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [54.209.41.153] 250-SIZE 35882577 "
SMTP -> get_lines(): $data was "250-smtp.gmail.com at your service, [54.209.41.153] 250-SIZE 35882577 "
SMTP -> get_lines(): $str is "250-8BITMIME "
SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [54.209.41.153] 250-SIZE 35882577 250-8BITMIME "
SMTP -> get_lines(): $data was "250-smtp.gmail.com at your service, [54.209.41.153] 250-SIZE 35882577 250-8BITMIME "
SMTP -> get_lines(): $str is "250-STARTTLS "
SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [54.209.41.153] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS "
SMTP -> get_lines(): $data was "250-smtp.gmail.com at your service, [54.209.41.153] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS "
SMTP -> get_lines(): $str is "250-ENHANCEDSTATUSCODES "
SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [54.209.41.153] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES "
SMTP -> get_lines(): $data was "250-smtp.gmail.com at your service, [54.209.41.153] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES "
SMTP -> get_lines(): $str is "250-PIPELINING "
SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [54.209.41.153] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-PIPELINING "
SMTP -> get_lines(): $data was "250-smtp.gmail.com at your service, [54.209.41.153] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-PIPELINING "
SMTP -> get_lines(): $str is "250-CHUNKING "
SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [54.209.41.153] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING "
SMTP -> get_lines(): $data was "250-smtp.gmail.com at your service, [54.209.41.153] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING "
SMTP -> get_lines(): $str is "250 SMTPUTF8 "
SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [54.209.41.153] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8 "
SMTP -> FROM SERVER: 250-smtp.gmail.com at your service, [54.209.41.153] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "220 2.0.0 Ready to start TLS "
SMTP -> get_lines(): $data is "220 2.0.0 Ready to start TLS "
SMTP -> FROM SERVER:220 2.0.0 Ready to start TLS
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "250-smtp.gmail.com at your service, [54.209.41.153] "
SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [54.209.41.153] "
SMTP -> get_lines(): $data was "250-smtp.gmail.com at your service, [54.209.41.153] "
SMTP -> get_lines(): $str is "250-SIZE 35882577 "
SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [54.209.41.153] 250-SIZE 35882577 "
SMTP -> get_lines(): $data was "250-smtp.gmail.com at your service, [54.209.41.153] 250-SIZE 35882577 "
SMTP -> get_lines(): $str is "250-8BITMIME "
SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [54.209.41.153] 250-SIZE 35882577 250-8BITMIME "
SMTP -> get_lines(): $data was "250-smtp.gmail.com at your service, [54.209.41.153] 250-SIZE 35882577 250-8BITMIME "
SMTP -> get_lines(): $str is "250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH "
SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [54.209.41.153] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH "
SMTP -> get_lines(): $data was "250-smtp.gmail.com at your service, [54.209.41.153] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH "
SMTP -> get_lines(): $str is "250-ENHANCEDSTATUSCODES "
SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [54.209.41.153] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH 250-ENHANCEDSTATUSCODES "
SMTP -> get_lines(): $data was "250-smtp.gmail.com at your service, [54.209.41.153] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH 250-ENHANCEDSTATUSCODES "
SMTP -> get_lines(): $str is "250-PIPELINING "
SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [54.209.41.153] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH 250-ENHANCEDSTATUSCODES 250-PIPELINING "
SMTP -> get_lines(): $data was "250-smtp.gmail.com at your service, [54.209.41.153] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH 250-ENHANCEDSTATUSCODES 250-PIPELINING "
SMTP -> get_lines(): $str is "250-CHUNKING "
SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [54.209.41.153] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING "
SMTP -> get_lines(): $data was "250-smtp.gmail.com at your service, [54.209.41.153] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING "
SMTP -> get_lines(): $str is "250 SMTPUTF8 "
SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [54.209.41.153] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8 "
SMTP -> FROM SERVER: 250-smtp.gmail.com at your service, [54.209.41.153] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "334 VXNlcm5hbWU6 "
SMTP -> get_lines(): $data is "334 VXNlcm5hbWU6 "
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "334 UGFzc3dvcmQ6 "
SMTP -> get_lines(): $data is "334 UGFzc3dvcmQ6 "
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "534-5.7.14 SMTP -> get_lines(): $data is "534-5.7.14 SMTP -> get_lines(): $data was "534-5.7.14 SMTP -> get_lines(): $str is "534-5.7.14 w1qusykfYpU2yVqlT4ZEIFrXPep3JwRh3FfzQc7ddey5QQmBd4JbZi9tNFSnBFHW7IdOcx "
SMTP -> get_lines(): $data is "534-5.7.14 SMTP -> get_lines(): $data was "534-5.7.14 SMTP -> get_lines(): $str is "534-5.7.14 NbZA5LEBoeSZEcjcwhBW_Kfziy5pHrZal2opZ3uBdoF-WM4OPoMDnfG_w_7fNOtjA8HGPw "
SMTP -> get_lines(): $data is "534-5.7.14 SMTP -> get_lines(): $data was "534-5.7.14 SMTP -> get_lines(): $str is "534-5.7.14 zL0OcSfQMG3sJ1fwVuYZTRL3prN6EZudpmCgygKIv1lqW9r7w8fXC5v-3qGXWP3PxghHp8 "
SMTP -> get_lines(): $data is "534-5.7.14 SMTP -> get_lines(): $data was "534-5.7.14 SMTP -> get_lines(): $str is "534-5.7.14 fVgbNTqeHZhv728Su3O-QGwFNdsU> Please log in via your web browser and "
SMTP -> get_lines(): $data is "534-5.7.14 Please log in via your web browser and "
SMTP -> get_lines(): $data was "534-5.7.14 Please log in via your web browser and "
SMTP -> get_lines(): $str is "534-5.7.14 then try again. "
SMTP -> get_lines(): $data is "534-5.7.14 Please log in via your web browser and 534-5.7.14 then try again. "
SMTP -> get_lines(): $data was "534-5.7.14 Please log in via your web browser and 534-5.7.14 then try again. "
SMTP -> get_lines(): $str is "534-5.7.14 Learn more at "
SMTP -> get_lines(): $data is "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 "
SMTP -> get_lines(): $data was "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 "
SMTP -> get_lines(): $str is "534 5.7.14 https://support.google.com/mail/answer/78754 c3sm6277150qge.12 - gsmtp "
SMTP -> get_lines(): $data is "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 c3sm6277150qge.12 - gsmtp "
SMTP -> ERROR: Password not accepted from server: 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 c3sm6277150qge.12 - gsmtp
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "250 2.1.5 Flushed c3sm6277150qge.12 - gsmtp "
SMTP -> get_lines(): $data is "250 2.1.5 Flushed c3sm6277150qge.12 - gsmtp "
SMTP -> FROM SERVER:250 2.1.5 Flushed c3sm6277150qge.12 - gsmtp
SMTP Error: Could not authenticate.
答案 0 :(得分:0)
我找到了解决这个问题的方法。您需要从链接强制访问不太安全的应用程序。 less secure apps setting或者如果您已经配置了来自Google邮件应用的电子邮件,请转到admin-> security->基本设置并执行上述操作。