2

我正在尝试在 codeigniter 中发送电子邮件,但出现了问题,我不知道如何修复它。当我在本地主机中发送时它成功,但是当我将我的应用程序上传到主机时,它无法发送。这是我的代码

        $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. 
4

2 回答 2

0

使用 codeigniter 发送 smtp gmail

1 - 确保您的 php 安装中的 openssl 是否已启用。

2- 此命令是脚本工作的基础: $this->email->set_newline("\r\n");

$config = 数组(

'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', '你的名字');

$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 'Your e-mail has been sent!'; 

完整解决方案链接:https ://ellislab.com/forums/viewthread/84689/

于 2014-12-01T14:54:32.863 回答
0

如果您需要授予对站点的 SMTP 服务器(您的电子邮件地址)的访问权限,以便执行身份验证,请查看您的电子邮件帐户是否未使用 difinições 安全性进行外部访问。

于 2013-11-12T12:33:11.973 回答