无法通过liveigniter在实时服务器上发送邮件

时间:2018-04-02 09:50:21

标签: php codeigniter email smtp backend

我在stackoverflow上尝试了很多东西,但仍然无法发送邮件,也许我的配置错了;代码在实时服务器中运行

      public function(){
    // configuration
    $config = Array(
      'protocol' => 'smtp',
      'smtp_host' => 'ssl://smtp.googlemail.com',
      'smtp_port' => 465,
      'smtp_user' => 'my_email', 
      'smtp_pass' => 'my_password', 
      'mailtype' => 'html',
      'charset'  => 'iso-8859-1',
      'wordwrap'   => true

    );
    $this->load->library('email',$config);
    $this->email->from('my_email','Administrator');
    $this->email->to('my_friends_email');
    $this->email->subject($subject);
    $this->email->message($message);
    return ($this->email->send()); }

2 个答案:

答案 0 :(得分:1)

试试这个

$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();

答案 1 :(得分:0)

如果主机帐户允许使用STMP中继或外部SMTP,则需要咨询您的服务器提供商。