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

时间:2019-08-05 09:20:15

标签: php

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

//配置内容

$protocol = 'sendmail';
$mailpath = '/usr/sbin/sendmail';
$charset = 'iso-8859-1';
$wordwrap = TRUE;
$mailtype= "html";
$smtp_host= "mail.domain.com";//pengaturan smtp
$smtp_port= "465";
$smtp_timeout= "25";
$user = "";
$pass = "";

//配置数组

$config                   = array();
$config['protocol']       = $protocol;
$config['mailpath']       = $mailpath;
$config['charset']        = $charset;
$config['wordwrap']       = $wordwrap;
$config['mailtype']       = $mailtype;
$config['smtp_host']      = $smtp_host;
$config['smtp_port']      = $smtp_port;
$config['smtp_timeout']   = $smtp_timeout;
$config['smtp_user']      = $user;
$config['smtp_pass']      = $pass;
$config['crlf']           = "\r\n";
$config['newline']        = "\r\n";
$config['send_multipart'] = FALSE;

//发送

$this->email->initialize($config);

$this->email->from($config['smtp_user'], 'Info');
$this->email->to($query['email']);
$this->email->subject("Reset password berhasil");
$this->email->message("adadad");
if ($this->email->send()) {
    echo "berhasil";
} 

1 个答案:

答案 0 :(得分:0)

好的sendmail允许您使用安装在本地服务器上的sendmail程序发送电子邮件。您的服务器上是否已安装sendmail。

您还已在配置文件中指定了SMTP连接设置。也许您不需要sendmail。尝试将协议字段从sendmail更改为smtp。