gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 20:25:12 24 4
gpt4 key购买 nike

我尝试使用 codeigniter 框架发送邮件。但它会引发错误“无法使用 PHP mail() 发送电子邮件。您的服务器可能未配置为使用此方法发送邮件。

From: "prakash t" <<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="087c787a6963697b60636b6d486f65696164266b6765" rel="noreferrer noopener nofollow">[email protected]</a>>
Return-Path: <<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5f2b2f2d3e343e2c37343c3a1f38323e3633713c3032" rel="noreferrer noopener nofollow">[email protected]</a>>
Reply-To: "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3e4a4e4c5f555f4d56555d5b7e59535f5752105d5153" rel="noreferrer noopener nofollow">[email protected]</a>" <<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c4b0b4b6a5afa5b7acafa7a184a3a9a5ada8eaa7aba9" rel="noreferrer noopener nofollow">[email protected]</a>>
X-Sender: <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d5a1a5a7b4beb4a6bdbeb6b095b2b8b4bcb9fbb6bab8" rel="noreferrer noopener nofollow">[email protected]</a>
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7b4e1a1e1f4f1e1e1f4f4b4e4b4d3b1c161a121755181416" rel="noreferrer noopener nofollow">[email protected]</a>>
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

”但没有用

这是我的代码:

公共(public)函数sendMail(){

    $config = Array(
'protocol' => 'mail',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 587,
'smtp_user' => 'e<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="463e272b362a2306212b272f2a6825292b" rel="noreferrer noopener nofollow">[email protected]</a>',
'smtp_pass' => '*********'
);

我知道这是重复的问题。但我没有找到问题的解决方案

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

$this->email->set_newline("\r\n");
$this->email->from('<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="add9dddfccc6ccdec5c6cec8edcac0ccc4c183cec2c0" rel="noreferrer noopener nofollow">[email protected]</a>','prakash t');
$this->email->to('<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7b0f0b091a101a08134a4a4a494a42424d3b1c161a121755181416" rel="noreferrer noopener nofollow">[email protected]</a>');
$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());
}

}

最佳答案

您已完成所有操作,但在初始化邮件时遇到问题

只需更改此

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

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

您可以查看in details here.

关于php - 无法使用 PHP mail() 发送电子邮件。您的服务器可能未配置为使用此方法发送邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50186498/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com