[英]An Error Was Encountered Unable to send email using PHP mail(). Your server might not be configured to send mail using this method
[英]Unable to send email using PHP mail(). Your server might not be configured to send mail using this method
我尝试使用 codeigniter 框架发送邮件。但它会引发错误“无法使用 PHP mail() 发送电子邮件。您的服务器可能未配置为使用此方法发送邮件。
From: "prakash t" <tprakashkce@gmail.com>
Return-Path: <tprakashkce@gmail.com>
Reply-To: "tprakashkce@gmail.com" <tprakashkce@gmail.com>
X-Sender: tprakashkce@gmail.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <5aed4eed40506@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
=?UTF-8?Q?Test=20Mail?=
hai this my test mail
"但没用
这是我的代码:
公共函数 sendMail(){
$config = Array(
'protocol' => 'mail',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 587,
'smtp_user' => 'example@gmail.com',
'smtp_pass' => '*********'
);
我知道这是重复的问题。但我没有找到我的问题的解决方案
$this->load->library('email',$config);
$this->email->set_newline("\r\n");
$this->email->from('tprakashkce@gmail.com','prakash t');
$this->email->to('tprakash11121996@gmail.com');
$this->email->subject('Test Mail');
$this->email->message('hai this my test mail');
if($this->email->send()){
echo "mail send succesfully";
}
else{
show_error($this->email->print_debugger());
}
}
我遇到了同样的错误,但我的问题出在 Apache 配置上。 确保 Apache 可以发送电子邮件。
要检查您当前的发送邮件状态: sestatus -b | grep httpd_can_sendmail
sestatus -b | grep httpd_can_sendmail
如果关闭,请将其更改为: sudo setsebool -P httpd_can_sendmail on
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.