使用phpmailer从Gmail发送电子邮件。登录错误 [英] Emailing from Gmail using phpmailer. Login Error

查看:86
本文介绍了使用phpmailer从Gmail发送电子邮件。登录错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎无法理解为什么我无法使用php中的各种邮件类发送电子邮件。我知道我的密码等是正确的。

I cant seem to get my head around why i cant send emails using all sorts of mail classes in php. I know my password etc is correct.

任何人有任何想法吗?

我收到错误消息:


SMTP->错误:服务器不接受密码:534-5.7.14请
通过您的网络浏览器和534登录-5.7.14,然后重试。 534-5.7.14
在534 5.7.14了解更多信息
https://support.google.com/mail/bin/answer.py?answer=78754
dm6sm8657044wib.22-gsmtp SMTP错误:无法进行身份验证。 Mailer
错误:SMTP错误:无法验证。

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/bin/answer.py?answer=78754 dm6sm8657044wib.22 - gsmtp SMTP Error: Could not authenticate. Mailer Error: SMTP Error: Could not authenticate.



function mail1($to,$body,$subject){

    include "/libs/mailer/classes/class.phpmailer.php"; // include the class name
    $mail = new PHPMailer(); // create a new object
    $mail->IsSMTP(); // enable SMTP
    $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->Host = "smtp.gmail.com";
    $mail->Port = 465; // or 587
    $mail->IsHTML(true);
    $mail->Username = "lewis.morris@gmail.com";
    $mail->Password = "xxxxxxxx";
    $mail->SetFrom("lewis.morris@gmail.com");
    $mail->Subject = $subject;
    $mail->Body = $body;
    $mail->AddAddress($to);

    if(!$mail->Send()){
        echo "Mailer Error: " . $mail->ErrorInfo;
    }
    else{
        echo "Message has been sent";
    }

}


推荐答案

此链接始终可以帮助我解决从我的应用程序到gmail的任何登录问题。试试这个可能对您有帮助。

This link always help me for any kind of login problem into gmail from my application. Try this may it can helps you...

在这里,请尝试登录不太安全的应用程序: https://www.google.com/settings/u/1/security/lesssecureapps

Here, trun on logging for less secure apps: https://www.google.com/settings/u/1/security/lesssecureapps

在这里,只需单击继续... https://accounts.google.com/b / 0 / DisplayUnlockCaptcha

Here, just click continue... https://accounts.google.com/b/0/DisplayUnlockCaptcha

并检查此处是否有任何日志记录到您的帐户: https://security.google.com/settings/security/activity?hl=zh-CN&pli=1

And check here is there any logging to your account: https://security.google.com/settings/security/activity?hl=en&pli=1

然后,运行您的代码。

这篇关于使用phpmailer从Gmail发送电子邮件。登录错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆