![](/img/trans.png)
[英]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.