Codeigniter:电子邮件发送工作正常,但没有收到电子邮件

时间:2016-03-24 16:34:24

标签: php codeigniter email

我是codeigniter中的电子邮件新手

我的控制器:

class Email extends CI_Controller
{

  public function __construct()
  {
    parent::__construct();
  }

  function index()
  {
    $config = array('protocol' => 'smpt',
                    'smtp_host' => 'belphegor.in-hell.com',
                    'smtp_port' => 465,
                    'smtp_user' => 'bla@blabla.com',
                    'smtp_pass' => 'blabla',
                    );

    $this->load->library('email',$config);
    $this->email->set_newline("\r\n");
    $this->email->from('bla@blabla.com', 'My Blabla');
    $this->email->to('apa@yahoo.com');
    $this->email->subject('Just test');
    $this->email->message('qwe adlw is alqopl slaod');

    if ($this->email->send()) {
      echo "email send";
    } else {
      show_error($this->email->debugger());
    }

  }
}

当我运行代码时显示“email send”,但是当我检查服务器时,外发电子邮件从未存在过。当我登录我的雅虎(apa@yahoo.com)时没有收到电子邮件。我该如何解决?

1 个答案:

答案 0 :(得分:0)

协议密钥上的配置数组有错误。

尝试更改:

 $config = array('protocol' => 'smpt',
                'smtp_host' => 'belphegor.in-hell.com',
                'smtp_port' => 465,
                'smtp_user' => 'bla@blabla.com',
                'smtp_pass' => 'blabla',
                );

到:

 $config = array('protocol' => 'smtp',
                    'smtp_host' => 'belphegor.in-hell.com',
                    'smtp_port' => 465,
                    'smtp_user' => 'bla@blabla.com',
                    'smtp_pass' => 'blabla',
                    );
相关问题