【问题标题】:Unable to send email无法发送电子邮件
【发布时间】:2013-09-22 04:43:09
【问题描述】:

在下面的代码点火器中,我想发送一封电子邮件,但我无法发送,请帮助我。

 <?php

/**
* SENDS EMAIL WITH GMAIL
*/
class Email extends CI_Controller
{
    function index() 
    {   
        $config = Array(
            'protocol' => 'smtp',
            'smtp_host' => 'ssl://smtp.googlemail.com',
            'smtp_port' => 465,
            'smtp_user' => 'sltechdevelop@gmail.com ',
            'smtp_pass' => 'highschool',
            'mailtype'  => 'html', 
            'charset'   => 'iso-8859-1'
            );
         $this->load->library('email', $config);
         $this->email->set_newline("\r\n");

         $this->email->from('sltechdevelop@gmail.com', 'moses');
         $this->email->to('sltechdevelop@gmail.com');       
         $this->email->subject('This is an email test');        
         $this->email->message('It is working. Great!');
         if($this->email->send())
         {
        echo 'Your email was sent, successfully.';
         }
         else
         {
        show_error($this->email->print_debugger());
          }
    }
}
?>

显示错误

The following SMTP error was encountered: 65272624 Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?
Unable to send data: AUTH LOGIN
Failed to send AUTH LOGIN command. Error: 
Unable to send data: MAIL FROM:

from: 
The following SMTP error was encountered: 
Unable to send data: RCPT TO:
to: 
The following SMTP error was encountered: 
Unable to send data: DATA
data: 
The following SMTP error was encountered: 
Unable to send data: User-Agent: CodeIgniter Date: Tue, 17 Sep 2013 16:54:03 +0000 From: "moses" Return-Path: To: sltechdevelop@gmail.com Subject: =?iso-8859-1?Q?This_is_an_email_test?= Reply-To: "sltechdevelop@gmail.com" X-Sender: sltechdevelop@gmail.com X-Mailer: CodeIgniter X-Priority: 3 (Normal) Message-ID: <5238892bc2bad@gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="B_ALT_5238892bc2bbc" This is a multi-part message in MIME format. Your email application may not support this format. --B_ALT_5238892bc2bbc Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit It is working. Great! --B_ALT_5238892bc2bbc Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable It is working. Great! --B_ALT_5238892bc2bbc--
Unable to send data: .

【问题讨论】:

标签: php codeigniter email


【解决方案1】:

这对我有用:

$config = Array(
    'protocol' => 'smtp',
    'smtp_host' => 'ssl://smtp.googlemail.com',
    'smtp_port' => 465,
    'smtp_auth' => true,
    'smtp_user' => 'xxx',
    'smtp_pass' => 'xxx',
    'mailtype'  => 'html', 
    'charset'   => 'iso-8859-1'
);
$this->load->library('email', $config);

详情请看这里:http://ellislab.com/forums/viewthread/132443/

【讨论】:

  • 我已经编辑了代码,但仍然没有解决错误我得到 fsockopen() [function.fsockopen]: 无法连接到 ssl://smtp.googlemail.com:465 (无法找到套接字传输“ssl” - 您在配置 PHP 时是否忘记启用它?)
【解决方案2】:

启用:php_openssl.dll 来自 php.ini,存在于您的 php 文件夹中

【讨论】:

    【解决方案3】:
     $config = array(
              'protocol' => 'smtp',
              'smtp_host' => 'ssl://smtp.secureserver.net',
              'smtp_port' => 465,
              'smtp_auth' => true,
              'smtp_user' => 'uername',
              'smtp_pass' => 'password',
              'mailtype' => 'html',
              'charset' => 'iso-8859-1'
              );
              $this->load->library('email', $config);
    

    【讨论】:

    • 请不要仅发布代码答案。请添加您正在做什么的详细信息。
    • @remya 你想得到墓地称号吗
    猜你喜欢
    • 2011-02-18
    • 1970-01-01
    • 2019-01-19
    • 2013-06-07
    • 2016-12-16
    • 2013-04-08
    • 2012-12-05
    • 2018-07-08
    相关资源
    最近更新 更多