本文介绍了如何使用codeigniter从本地主机发送电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
function sendMail() {
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => '[email protected]',
'smtp_pass' => 'xxx',
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
$message = 'test';
$this->load->library('email', $config);
$this->email->set_newline("
");
$this->email->from('[email protected]');
$this->email->to('[email protected]');
$this->email->subject('testing');
$this->email->message($message);
if($this->email->send())
{
echo 'Email sent.';
}
else
{
show_error($this->email->print_debugger());
}
}
这是我的代码,我正在尝试使用 codeigniter 从本地主机发送电子邮件,我收到消息电子邮件已发送".但我没有在 Gmail 帐户中收到任何邮件.
推荐答案
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => '[email protected]',// your mail name
'smtp_pass' => '*****',
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
然后
$this->load->library('email', $config);
XAMPP 中的邮件设置(无能)
$this->email->from('[email protected]', 'myname');//your mail address and name
$this->email->to('[email protected]'); //receiver mail
$this->email->subject('testing');
$this->email->message($message);
$this->email->send(); //sending mail
sendmail.ini
路径 c:xamppsendmailsendmail.ini
配置
[sendmail]
smtp_server=smtp.gmail.com
smtp_port=25
error_logfile=error.log
debug_logfile=debug.log
[email protected]
auth_password=yourgmailpassword
[email protected]
在php.ini
pathc:xamppxamppphpphp.ini
[mail function]
sendmail_path = ""C:xamppsendmailsendmail.exe" -t"
这篇关于如何使用codeigniter从本地主机发送电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!