我正在尝试在codeigniter中发送电子邮件,但有些不对劲,我不知道如何修复它。 当我发送localhost时它成功,但是当我将我的应用程序上传到主机时,它无法发送。这是我的代码
$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();
当我提交电子邮件时,这是我的错误
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.
答案 0 :(得分:0)
如果您需要授予对您网站的SMTP服务器(您的电子邮件地址)的访问权限,以便您可以执行身份验证,请查看您的电子邮件帐户是否处于非活动状态,并具有外部访问的安全性。
答案 1 :(得分:0)
使用codeigniter发送smtp gmail autenticated
1 - 确保你的php instalation中的openssl是否已启用。
2-此命令是脚本工作的基础:$ 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);
$这 - >的电子邮件 - > set_newline(" \ r \ n&#34);
$ this-> email-> from(' gmail.login@googlemail.com',' Your Name');
$这 - >的电子邮件 - >到(' recipient@destination.tld');
$ this-> email-> subject(' CodeIgniter Rocks Socks');
$ this-> email->消息(' Hello World');
if(!$ this-> email-> send())
show_error($this->email->print_debugger());
否则
echo 'Your e-mail has been sent!';