【发布时间】:2021-06-29 20:57:53
【问题描述】:
我正在尝试通过 Gmail SMTP 使用 CodeIgniter 发送电子邮件,但该功能无法正常工作,它在 localhost 上显示此错误?
An Error Was Encountered Unable to send email using PHP mail().
Your server might not be configured to send mail using this method.
这是我的电子邮件功能
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => '******@gmail.com', // change it to yours
'smtp_pass' => '**********', // change it to yours
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
$message = 'Test';
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('*********@gmail.com'); // change it to yours
$this->email->to('test@gmail.com');// change it to yours
$this->email->subject('Resume from JobsBuddy for your Job posting');
$this->email->message($message);
if($this->email->send())
{
echo 'Email sent.';
}
else
{
show_error($this->email->print_debugger());
}
【问题讨论】:
-
大部分主机管理员,阻止
mail()功能,你可以试试smtp之类的东西 -
@AKiani 但我必须在不同的 Codeigniter 应用程序上尝试相同的代码,它工作正常吗?
标签: php codeigniter email smtp gmail