无法通过codeigniter中的Gmail发送电子邮件,SMTP身份验证错误 [英] Can't send email from gmail in codeigniter, SMTP Authentication error
问题描述
我试图在codeigniter中发送一封电子邮件,但有些错误,我不知道如何解决它。
我在本地主机发送成功,但是当我上传我的应用到主机时,它不能发送。这是我的代码
$ this->加载 - >库('email');
$ config ['protocol'] ='smtp';
$ config ['smtp_host'] ='ssl://smtp.gmail.com';
$ config ['smtp_port'] ='465';
$ config ['smtp_timeout'] ='7';
$ config ['smtp_user'] ='用户名';
$ config ['smtp_pass'] ='****';
$ config ['charset'] ='utf-8';
$ config ['newline'] =\r\\\
;
$ config ['mailtype'] ='html'; //或html
$ config ['validation'] = TRUE; // bool是否验证电子邮件
$ this-> email->初始化($ config);
$ this-> email-> send();
echo $ this-> email-> print_debugger();
这是我提交电子邮件时的错误
验证密码失败。错误:535错误的验证数据
* from:250 OK
to:550-请在您的邮件客户端打开SMTP验证,或登录
550-IMAP / POP3服务器发送您的消息之前。 mb2d247.vdrs.net
550-(hanghieunara.com)[112.78.2.247]:51939不允许通过
550转发此服务器而不进行身份验证。*
以下遇到SMTP错误:550-请在您的邮件客户端中打开SMTP身份验证,或者在发送邮件之前登录到550-IMAP / POP3服务器。
mb2d247.vdrs.net 550-(hanghieunara.com)[112.78.2.247]:51939不允许在没有身份验证的情况下通过550中继该服务器。
发送smtp gmail与codeigniter一起验证
1 - 确保您的php安装中的openssl已启用。
2-此命令对于脚本工作非常重要:$ this-> email-> set_newline(\r\\\
);
$ config = Array(
) 'protocol'=>'smtp',
'smtp_host'=>'ssl://smtp.googlemail.com',
'smtp_port '=> 465,
'smtp_user'=>'gmail.login@googlemail.com',
'smtp_pass'=>'your_password',
);
$ this-> load-> library('email',$配置);
$ this-> email-> set_newline(\r\\\
);
< ('gmail.login@googlemail.com','您的姓名');
$ this-> email-> to ('recipient@destination.tld');
$ this-> email-> subject('CodeIgniter Rocks Socks');
$ this-> email-> message('Hello World');
if(!$ this-> email-> send())
show_error($ this-> email-> print_debugger());
其他
echo'您的电子邮件已发送!';
完整解决方案链接: https://ellislab.com/forums/viewthread/84689/
I'm trying to send an email in codeigniter, but something wrong and i dont know how to fix it. It success when I send in localhost, but when I upload my app into host, it cant send. This is my code
$this->load->library('email');
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.gmail.com';
$config['smtp_port'] = '465';
$config['smtp_timeout'] = '7';
$config['smtp_user'] = 'username';
$config['smtp_pass'] = '****';
$config['charset'] = 'utf-8';
$config['newline'] = "\r\n";
$config['mailtype'] = 'html'; // or html
$config['validation'] = TRUE; // bool whether to validate email or not
$this->email->initialize($config);
$this->email->send();
echo $this->email->print_debugger();
And this is my error when I submit an email
Failed to authenticate password. Error: 535 Incorrect authentication data
*from: 250 OK
to: 550-Please turn on SMTP Authentication in your mail client, or login to the
550-IMAP/POP3 server before sending your message. mb2d247.vdrs.net
550-(hanghieunara.com) [112.78.2.247]:51939 is not permitted to relay through
550 this server without authentication.*
The following SMTP error was encountered: 550-Please turn on SMTP Authentication in your mail client, or login to the 550-IMAP/POP3 server before sending your message.
mb2d247.vdrs.net 550-(hanghieunara.com) [112.78.2.247]:51939 is not permitted to relay through 550 this server without authentication.
To send smtp gmail autenticated with codeigniter
1 - Be sure if openssl in your php instalation is enabled.
2- This command is fundamental to script works: $this->email->set_newline("\r\n");
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'gmail.login@googlemail.com',
'smtp_pass' => 'your_password',
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('gmail.login@googlemail.com', 'Your Name');
$this->email->to('recipient@destination.tld');
$this->email->subject(' CodeIgniter Rocks Socks ');
$this->email->message('Hello World');
if (!$this->email->send())
show_error($this->email->print_debugger());
else
echo 'Your e-mail has been sent!';
Full solution link: https://ellislab.com/forums/viewthread/84689/
这篇关于无法通过codeigniter中的Gmail发送电子邮件,SMTP身份验证错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!