首页 文章

Codeigniter在mamp上发送电子邮件

提问于
浏览
1

我正在使用codeigniter及其电子邮件类尝试在MAMP上发送电子邮件(免费版)

我的代码如下

$ config = Array('protocol'=>'smtp',
'smtp_host'=>'ssl://smtp.googlemail.com',
'smtp_port'=> 465,
'smtp_user'=>'test@gmail.com.sg',
'smtp_pass'=>'*********',
'mailtype'=>'html',
'starttls'=>是的
);

$ this-> load-> library('email',$ config);
$这 - >的电子邮件 - > set_newline( “\ r \ n”);

$ this-> email-> from('test@gmail.com.sg','Jeffrey Way');
$这 - >的电子邮件 - >到('test_to@gmail.com.sg');
$ this-> email-> subject('这是一个电子邮件测试');
$ this-> email-> message('它正在工作 . 很棒!');
$这个 - >的电子邮件 - >发送();
echo $ this-> email-> print_debugger();

但是我总是得到一个错误

220 mx.google.com ESMTP ri1sm17015935pbc.16 - gsmtp hello:250-mx.google.com为您服务,[203.116.128.34] 250-SIZE 35882577 250-8BITMIME 250-AUTH登录平台XOAUTH XOAUTH2 250 ENHANCEDSTATUSCODES无法验证密码 . 错误:535-5.7.1不接受用户名和密码 . 如需了解详情,请访问535 5.7.1 http://support.google.com/mail/bin/answer.py?answer=14257 ri1sm17015935pbc.16 - gsmtp from:530-5.5.1需要验证 . 如需了解更多信息,请访问530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 ri1sm17015935pbc.16 - gsmtp遇到以下SMTP错误:530-5.5.1需要验证 . 要了解详情,请访问530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 ri1sm17015935pbc.16 - gsmtp to:530-5.5.1需要验证 . 如需了解更多信息,请访问530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 ri1sm17015935pbc.16 - gsmtp

在此先感谢您的帮助 .

2 回答

  • 0
    Authentication Required.
    

    您使用的不是您自己的Gmail帐户(电子邮件和密码)

  • 0

    我在很多地方都看过这个问题,当然,我在这里是因为我有同样的问题 . 我认为发生的事情是,当Jeffrey Way在2009年编写教程(Day 3,我从中获取代码的地方)时,发送电子邮件的身份验证非常简单 . 我认为's different now with Google. You have to use an oauth2 authentication flow. I have managed to find such a code for CodeIgniter, and can authenticate, but I still don' t非常了解认证后要做什么 . 我猜测,在您允许该应用访问您的Google信息之后,回调页面就是您放置实际发送邮件代码的位置(您在问题中的代码) . 所以,我认为这是一个由两部分组成的过程:

    • 使用oAuth2和Google对Google进行身份验证

    • 您的 endpoints 是发送电子邮件的回调页面(您的上述示例代码来自Way教程) .

    你只想发送一封电子邮件,我知道,我也是 . 但我想你可能想复制并粘贴并尝试这个工作脚本:

    Login with google account in codeigniter

相关问题