我使用smtp设置在codeigniter中发送电子邮件
//smtp settings
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.gmail.com';
$config['smtp_port'] = 465;
$config['smtp_user'] = '****@*****.***';
$config['smtp_pass'] = '*****';
$this->load->library('email', $config);
$this->email->from('*****@*******.****', '******');
$this->email->to('******@********.****');
$this->email->subject('email subject ');
$this->email->message("my email messages");
if($this->email->send()){
echo "done";
}
i)我收到了“完成”消息。
ii)在接收方电子邮件上收到电子邮件($ this-> email-> to('{@@@..');)
但是我的smtp gmail帐户(收件箱/已发送)中没有收到任何通知。
如何确保smtp正常工作?
答案 0 :(得分:0)
在live server
中的application / config /文件夹中创建email.php文件位置:application / config / email.php
<?php
/*
* Protocol name TROFEO SOFTWARE SOLUTIONS
*/
$config['protocol'] = 'smtp';
/*
* smtp_host name for mail sending.
* this
*/
//developers server name for smtp host
$config['smtp_host'] = 'smtp.gmail.com';
//smtp port
$config['smtp_port'] = 587;
//smtp user
$config['smtp_user'] = '******@***.**';
//smtp password
$config['smtp_pass'] = '************';
/*
*mail type send to user
*/
$config['mailtype']="html";
/*
* Character set of the mail
*/
$config['charset'] = 'iso-8859-1';
/*
*Wordwrap flag of the mail
*/
$config['wordwrap'] = TRUE;
/*
New line character
*/
$config['newline']= "\r\n";
然后在您的控制器中
$this->load->library('email');
$this->email->from('*****@*******.****', '******');
$this->email->to('******@********.****');
$this->email->subject('email subject ');
$this->email->message("my email messages");
if($this->email->send()){
echo "done";
}