简体   繁体   English

通过Codeigniter将邮件发送到Gmail帐户失败

[英]Sending mail to a gmail account via codeigniter fails

I tried to send a email to a Gmail account (both receiver and sender accounts were created by me and both allow access to less secured apps) via CodeIgniter, using the following settings (from my localhost WAMP sever): 我尝试使用以下设置(通过我的本地主机WAMP服务器)通过CodeIgniter将电子邮件发送到Gmail帐户(接收者和发送者帐户均由我创建,并且都允许访问安全性较低的应用程序):

$config['smtp_user']='my gmail address';
$config['smtp_pass']='my password';
$config['smtp_port']=465;
$config['smtp_host']='ssl://smtp.googlemail.com';
$config['charset']='utf-8';
$config['protocol'] ='smtp';

The code snippet looks like this : 该代码段如下所示:

$this->email->from(my gmail address... , 'admin');
$this->email->to($reciever_email);
$this->email->subject(...);
$this->email->message(...);
$this->email->send();

But the mail does not get send (No weird error messages like fatal error etc. is displayed only the custom message I decided to show on failure is shown). 但是邮件不会发送(不会显示致命错误等奇怪的错误消息,只会显示我决定在失败时显示的自定义消息)。

Can any one tell me why and how to get rid of this problem. 谁能告诉我为什么以及如何摆脱这个问题。

Try this instead: 尝试以下方法:

$config = Array(
         'protocol' => 'smtp',
         'smtp_host' => 'ssl://smtp.googlemail.com',
         'smtp_port' => '465',
         'smtp_user' => 'my user',
         'smtp_pass' => 'my password',
         'smtp_charset' => 'utf-8'
);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM