简体   繁体   English

无法使用 PHP mail() 发送电子邮件。 您的服务器可能未配置为使用此方法发送邮件

[英]Unable to send email using PHP mail(). Your server might not be configured to send mail using this method

i tried to send the mail using codeigniter framework.but it will raise the error "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

" but no use "但没用

here is mycode:这是我的代码:

public function sendMail(){公共函数 sendMail(){

    $config = Array(
        'protocol' => 'mail',
        'smtp_host' => 'ssl://smtp.googlemail.com',
        'smtp_port' => 587,
        'smtp_user' => 'example@gmail.com',
        'smtp_pass' => '*********'
    );

I know it's duplicate question.but i didn't find solution for my question我知道这是重复的问题。但我没有找到我的问题的解决方案

    $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());
    }

}

You are done all correct but you have issue on initialize the mail您已完成所有正确操作,但在初始化邮件时遇到问题

Just change this只需改变这个

$this->load->library('email',$config);

to

$this->load->library('email');
$this->email->initialize($config);

You can check in details here.您可以在此处查看详细信息。

I got same error but my problem was with Apache configuration.我遇到了同样的错误,但我的问题出在 Apache 配置上。 Ensure that Apache can send emails.确保 Apache 可以发送电子邮件。

To check your current sendmail status: sestatus -b | grep httpd_can_sendmail要检查您当前的发送邮件状态: sestatus -b | grep httpd_can_sendmail sestatus -b | grep httpd_can_sendmail

Change it to this if it is off: sudo setsebool -P httpd_can_sendmail on如果关闭,请将其更改为: sudo setsebool -P httpd_can_sendmail on

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 遇到错误无法使用 PHP mail() 发送 email。 您的服务器可能未配置为使用此方法发送邮件 - An Error Was Encountered Unable to send email using PHP mail(). Your server might not be configured to send mail using this method Codeigniter:您的服务器可能未配置为使用此方法发送邮件。 无法使用 PHP SMTP 发送电子邮件 - Codeigniter: Your server might not be configured to send mail using this method. Unable to send email using PHP SMTP 无法使用 PHP SMTP 发送 email。您的服务器可能未配置为使用此方法发送邮件 - Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method 无法使用 PHP Sendmail 发送电子邮件。 您的服务器可能未配置为使用此方法发送邮件 - Unable to send email using PHP Sendmail. Your server might not be configured to send mail using this method Codeigniter 3 无法使用 PHP ZC2239A92BDE29F0A00F9173193CC2FE 发送 email。 您的服务器可能未配置为使用此方法发送邮件 - Codeigniter 3 Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method 无法使用codeigniter发送电子邮件-错误:您的服务器可能未配置为使用此方法发送邮件 - Unable to send email using codeigniter-Error:Your server might not be configured to send mail using this method 无法使用 PHP SMTP 发送电子邮件。 您的服务器可能未配置为使用此方法发送邮件 - Unable to send email using PHP SMTP. Your server might not be configured to send mail using this methods CodeIgniter中的AWS SMTP邮件错误(无法使用PHP SMTP发送电子邮件。您的服务器可能未配置为使用此方法发送邮件。) - AWS SMTP mail error in CodeIgniter (Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.) 无法发送AUTH LOGIN命令。 错误:无法使用PHP SMTP发送电子邮件。 您的服务器可能未配置为使用此方法发送邮件 - Failed to send AUTH LOGIN command. Error: Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method 您的服务器可能未配置为使用此方法发送邮件 - Your server might not be configured to send mail using this method
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM