gpt4 book ai didi

php - SMTP 邮件未发送 - Codeigniter 电子邮件库

转载 作者:行者123 更新时间:2023-12-03 09:00:19 25 4
gpt4 key购买 nike

我在通过 SMTP 协议(protocol)发送邮件时遇到问题。

Welcome.php

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

$config = array();
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.zoho.com';
$config['smtp_user'] = '<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d3a0a6a3a3bca1a793b7bcbeb2babdfdb0bcbe" rel="noreferrer noopener nofollow">[email protected]</a>';
$config['smtp_pass'] = '**************';
$config['smtp_port'] = 465;
$config["smtp_crypto"] = "ssl";

$this->email->initialize($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="3b484e4b4b54494f7b5f54565a525515585456" rel="noreferrer noopener nofollow">[email protected]</a>', 'Support name'); // change it to yours
$this->email->to($to);// change it to yours
$this->email->subject($subject);
$this->email->message($message);

if($this->email->send())
{
echo "Success! - An email has been sent to ".$to;
}
else
{
show_error($this->email->print_debugger());
return false;
}
}

这是输出错误:

An Error Was Encountered
220 mx.zohomail.com SMTP Server ready June 29, 2018 5:16:40 AM PDT

hello:

The following SMTP error was encountered:
Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.
Date: Fri, 29 Jun 2018 12:16:40 +0000
From: "Support Name" <<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9cefe9ececf3eee8dcf8f3f1fdf5f2b2fff3f1" rel="noreferrer noopener nofollow">[email protected]</a>>
Return-Path: <<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="afdcdadfdfc0dddbefcbc0c2cec6c181ccc0c2" rel="noreferrer noopener nofollow">[email protected]</a>>
To: <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d4a6b1b7bda4b1baa094b3b9b5bdb8fab7bbb9" rel="noreferrer noopener nofollow">[email protected]</a>
Subject: =?ISO-8859-1?Q?=43=6F=70=79=20=61=6C=6C=20=74=68=65?=
Reply-To: <<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d9aaaca9a9b6abad99bdb6b4b8b0b7f7bab6b4" rel="noreferrer noopener nofollow">[email protected]</a>>
User-Agent: CodeIgniter
X-Sender: <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5b282e2b2b34292f1b3f34363a323575383436" 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="5c693e6f6a6e6f6e64686c6965691c3833313d3532723f3331" rel="noreferrer noopener nofollow">[email protected]</a>>
Mime-Version: 1.0


Content-Type: multipart/alternative; boundary="B_ALT_5b3623284061c"

This is a multi-part message in MIME format.
Your email application may not support this format.

--B_ALT_5b3623284061c
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit

Some


--B_ALT_5b3623284061c
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Some Email Description=0A=0A Some Email Description

--B_ALT_5b3623284061c--

Note: The script is working fine on localhost, as well as multiple other hostings but not working on VPS Hosting.

以下是要记住的事情:

  1. 代码很好(在不同的托管中尝试过并且有效)
  2. $config['protocol'] = "smtp"; 更改为 $config['protocol'] = "sendmail"; 即可。但我只想通过 SMTP 协议(protocol)发送邮件。
  3. 使用 Zoho Mail SMTP 协议(protocol) (smtp.zoho.com)
  4. 尝试过 Google SMTP,仍然无法发送。 (使用 PHPMailer 库来测试凭据。它正在处理它们。)

最佳答案

我希望这段代码工作正常

$Config = [
'protocol' => 'smtp',
'smtp_host' => 'smtp.zoho.com',
'smtp_port' => 465,
'smtp_user' => '<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="60131510100f121420040f0d01090e4e030f0d" rel="noreferrer noopener nofollow">[email protected]</a>',
'smtp_pass' => '**************',
'mailtype' => 'html',
'charset' => 'utf-8'
];
$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="92e1e7e2e2fde0e6d2f6fdfff3fbfcbcf1fdff" rel="noreferrer noopener nofollow">[email protected]</a>', 'Support name'); // change it to yours
$this->email->to($to);// change it to yours
$this->email->subject($subject);
$this->email->message($message);
if($this->email->send()){
echo "Success! - An email has been sent to ".$to;
}
else{
show_error($this->email->print_debugger());
return false;
}

关于php - SMTP 邮件未发送 - Codeigniter 电子邮件库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51102050/

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