gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-10-31 23:54:42 26 4
gpt4 key购买 nike

我正在使用 codeigniter

我在实时服务器上执行了代码。使用 print_debugger() 出现以下错误

Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.

public function sendEnquiry() {
$this->load->library('email');
$name = $this->input->post("fname");
$cemail = $this->input->post("email");
$pno = $this->input->post("phone");
$message = $this->input->post("message");
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://mail.gatewaykhobar.com';
$config['smtp_port'] = '465';
$config['smtp_timeout'] = '7';
$config['smtp_user'] = '***********';
$config['smtp_pass'] = '***********';
$config['charset'] = 'utf-8';
$config['newline'] = "\r\n";
$config['mailtype'] = 'text'; // or html
$config['validation'] = FALSE;

$this->email->initialize($config);
$this->email->from('info@gatewaykhobar.com','Gateway Restaurent Contact');
$this->email->to($cemail);
$this->email->subject('Gateway Restaurent Contact Enquiry');

$this->email->message($message);
$send = $this->email->send();
if($send) {
echo json_encode("send");
} else {
$error = $this->email->print_debugger(array('headers'));
echo json_encode($error);
}

}

最佳答案

smtp_port 从 465 更改为 587。

确保 $config['newline'] = "\r\n"; 是双引号而不是单引号。

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

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