【问题标题】:CodeIgniter Email without SMTP not working没有 SMTP 的 CodeIgniter 电子邮件不起作用
【发布时间】:2019-01-11 06:53:25
【问题描述】:

我正在使用 CI 电子邮件模块,但它不起作用。我没有 SMTP 凭据,因此尝试使用此代码为我工作。

   $this->load->library('email');
    // Send Emails
    $config = Array(
        'mailtype' => 'html'
    );
    $this->email->initialize($config);
    $this->email->set_newline("\r\n");
    $this->email->from($from);
    $this->email->to($to);
    $this->email->subject($title);
    $this->email->message($message);
    //$this->email->send();
    if ($this->email->send()) {
        $this->email->clear();
        return true;
    } else {
        die(show_error($this->email->print_debugger()));
        //return false; 
    }

它给出了这个错误

【问题讨论】:

  • 如消息所述,您的服务器未配置为使用配置的方法发送电子邮件。也许它设置为使用sendmail 发送而不安装sendmail?我建议使用 SMTP,因为这将使您的代码更便携,并确保更多人可以收到您的电子邮件。

标签: php codeigniter email smtp


【解决方案1】:

电子邮件通常由电子邮件服务器发送。

如果您没有指定 SMTP 服务器,您的电子邮件模块正在尝试使用内置的 php email 函数发送电子邮件。

但是这个函数并不神奇。它还需要一个功能齐全的 SMTP 服务器/代理。

默认情况下,在 Unix 平台上,它使用本地 SMTP 服务器,在 php.ini sendmail_path 中指定。在 Windows 上,需要在SMTP 参数中指定。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-11-03
    • 2014-07-05
    • 2012-08-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-23
    • 2014-06-07
    相关资源
    最近更新 更多