【问题标题】:CodeIgniter email sending errorCodeIgniter 电子邮件发送错误
【发布时间】:2016-05-06 20:28:27
【问题描述】:

我正在尝试使用 CodeIgniter 发送电子邮件,这是我的代码

function sendmail()
    {
            // Set SMTP Configuration
            $emailConfig = array(
               'protocol' => 'smtp',
                'smtp_host' => 'TLS://smtp.googlemail.com',
                'smtp_port' => 587,
                'smtp_user' => 'email@gmail.com',
                'smtp_pass' => '******',
                'mailtype'  => 'html',
                'charset'   => 'iso-8859-1'
            );

            // Set your email information
            $from = array('email' => 'frommail@gmail.com', 'name' => 'Your Name');
            $to = array('mymail@gmail.com');
            $subject = 'Your gmail subject here';

            $message = 'Type your gmail message here';
            // Load CodeIgniter Email library
            $this->load->library('email', $emailConfig);

            // Sometimes you have to set the new line character for better result
            $this->email->set_newline("rn");
            // Set email preferences
            $this->email->from($from['email'], $from['name']);
            $this->email->to($to);

            $this->email->subject($subject);
            $this->email->message($message);
            // Ready to send email and check whether the email was successfully sent

            if (!$this->email->send()) {
                // Raise error message
                show_error($this->email->print_debugger());
            }
            else {
                // Show success notification or other things here
                echo 'Success to send email';
            }

    }

但它给了我这种类型的错误

遇到以下 SMTP 错误:110 连接超时 无法发送数据:AUTH LOGIN 发送 AUTH LOGIN 命令失败。 错误:无法发送数据:MAIL FROM:

来自:

遇到以下 SMTP 错误:无法发送数据:RCPT 到:

到:

遇到以下 SMTP 错误:无法发送数据:DATA

数据:

遇到以下 SMTP 错误:无法发送数据: 用户代理:CodeIgniter 日期:2016 年 1 月 29 日星期五 06:59:14 +0000 来自: “Alex Tester”返回路径:至:coderjack9@gmail.com 主题: =?iso-8859-1?Q?Email_Test?= 回复:“alextester1003@gmail.com” X-Sender:alextester1003@gmail.com X-Mailer:CodeIgniter X-Priority:3 (正常)消息 ID: Mime 版本:1.0 内容类型:多部分/替代;边界="B_ALT_56ab0dc2af809" 这是 MIME 格式的多部分消息。您的电子邮件应用程序 可能不支持这种格式。 --B_ALT_56ab0dc2af809 内容类型: 文本/纯文本; charset=iso-8859-1 内容传输编码:8 位测试 电子邮件类。 --B_ALT_56ab0dc2af809 内容类型:文本/html; charset=iso-8859-1 内容传输编码:引用打印测试 电子邮件类。 --B_ALT_56ab0dc2af809-- 无法发送数据:.

遇到以下 SMTP 错误:无法使用以下方式发送电子邮件 PHP SMTP。您的服务器可能未配置为使用此功能发送邮件 方法。

【问题讨论】:

    标签: php codeigniter email smtp


    【解决方案1】:
     $this->load->library('email');
      $this->load->library('user_agent');    
      $this->email->from(from@gmail.com);
      $this->email->to(to@gmail.com);   
      $this->email->cc(cc@gmail.com); 
       $this->email->subject('sub');$this->email->message($messages);   
     $this->email->send();
    

    注意:邮件无法发送本地主机。如果您尝试实时网站。

    【讨论】:

    • 我正在实时服务器上尝试这个
    【解决方案2】:

    用户这个

    $config = Array(
        'protocol' => 'smtp',
        'smtp_host' => 'ssl://smtp.googlemail.com',
        'smtp_port' => 465,
        'smtp_user' => 'xxx',
        'smtp_pass' => 'xxx',
        'mailtype'  => 'html', 
        'charset'   => 'iso-8859-1'
    );
    $this->load->library('email', $config);
    $this->email->set_newline("\r\n");
    
    // Set to, from, message, etc.
    
    $result = $this->email->send();
    

    【讨论】:

      猜你喜欢
      • 2015-03-17
      • 2016-09-02
      • 2013-01-07
      • 2019-08-07
      • 1970-01-01
      • 1970-01-01
      • 2018-05-24
      • 2012-12-16
      • 2015-04-09
      相关资源
      最近更新 更多