提问人:Foozaweb 提问时间:1/9/2022 最后编辑:Foozaweb 更新时间:1/11/2022 访问量:71
CodeIgniter 的电子邮件送达率问题。我的代码返回已发送的电子邮件,但未传递给 VPS 服务器上的收件人
Issues with email deliverability with CodeIgniter. my code returns email sent, but doesn't get delivered to the recipient on a vps server
问:
这是我的代码。我尝试使用“邮件”作为协议,但仍然无法交付。但它确实可以在 localhost 和其他服务器上完美地交付。但是在这个特定的 vps 服务器上,它没有。提前致谢。
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => '[email protected]',
'smtp_pass' => '***********',
'smtp_timeout' => 10,
'mailtype' => 'html',
'starttls' => true,
'newline' => "\r\n",
);
$this->load->library('email');
$this->email->initialize($config);
$this->email->from($sender);
$this->email->to($email);
$this->email->subject($subject);
$this->email->message($mailToSend);
$flag = $this->email->send();
if ($flag) {
return $flag;
} else {
return false;
}
答:
1赞
ganji
1/10/2022
#1
删除
$this->email->initialize($config);
行,让 Codeigniter 使用它的默认参数。 或者使用此配置
$config['useragent'] = 'PHPMailer';
$config['protocol'] = 'mail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['smtp_host'] = 'localhost';
$config['smtp_user'] = '';
$config['smtp_pass'] = '';
$config['smtp_port'] = 25;
$config['smtp_timeout'] = 30;
$config['smtp_crypto'] = '';
$config['smtp_debug'] = 0;
$config['smtp_auto_tls'] = true;
$config['smtp_conn_options'] = array();
$config['wordwrap'] = true;
$config['wrapchars'] = 76;
$config['mailtype'] = 'html';
$config['charset'] = null;
$config['validate'] = true;
$config['priority'] = 3;
$config['crlf'] = "\n";
$config['newline'] = "\n";
$config['bcc_batch_mode'] = false;
$config['bcc_batch_size'] = 200;
$config['encoding'] = '8bit';
$this->电子邮件->初始化($config);
评论
0赞
Foozaweb
1/10/2022
感谢您的回复。但这也行不通
0赞
ganji
1/11/2022
@Foozaweb 您是否检查了远处的批量或垃圾邮件文件夹?
0赞
Foozaweb
1/11/2022
是的。但什么也没进来。
0赞
Foozaweb
1/10/2022
#2
我收到了这个,它似乎可以发送邮件,但问题是它没有发送给收件人。相反,它会将其发送到 webMail。
$this->load->library('email');
$config['mailtype'] = 'html';
$config['protocol'] = 'sendmail';
$config['smtp_port'] = '465';
$config['mailpath'] = '/usr/sbin/sendmail';
$this->email->initialize($config);
$this->email->message($mailToSend);
$this->email->subject($subject);
$this->email->from($sender);
$this->email->reply_to("[email protected]");
$this->email->to($email);
// Set recipients
$this->email->bcc_batch_mode = true;
$this->email->bcc_batch_size = 50;
$this->email->bcc("[email protected]);
set_time_limit(0);
ignore_user_abort(true);
// Send this mailing
$flag = $this->email->send();
if ($flag) {
return $flag;
} else {
return false;
}
1赞
Foozaweb
1/11/2022
#3
[已解决] 问题出在邮件头上。我没有设置标题。这是一个工作示例
$config = array(
'protocol' => 'sendmail',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => '465',
'smtp_user' => '[email protected]',
'smtp_pass' => '****',
'smtp_timeout' => 50,
'mailtype' => 'html',
'starttls' => true,
'charset' => 'utf-8',
'protocol' => 'sendmail',
'mailpath' => '/usr/sbin/sendmail',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE,
);
$this->load->library('email');
$this->email->initialize($config);
$this->email->set_header('X-Mailer', 'CodeIgniter');
$this->email->set_header('X-Priority', '1');
$this->email->set_header('Subject', $subject);
$this->email->set_header('Mime-Version', '1.0');
$this->email->set_header('Importance', 'High');
$this->email->set_header('X-MSMail-Priority', 'High');
$this->email->set_newline("\r\n");
$this->email->from('[email protected]', $sender);
$this->email->to($email);
$this->email->cc('[email protected]');
$this->email->subject($subject);
$this->email->message($mailToSend);
$flag = $this->email->send();
if ($flag) {
return $flag;
} else {
return false;
}
评论