如何通过Codeginiter中的Gmail SMTP发送电子邮件


how to send email through gmail smtp in codeginiter?

我的网站在 Godaddy 主机上,它的 PHP 版本为 5.4.34。我使用了代码点火器电子邮件库,我在电子邮件中配置了以下设置.php在配置文件夹下。

<?php
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.gmail.com';
$config['smtp_port'] = '465';
$config['smtp_user'] = 'gmail account email';
$config['smtp_pass'] = 'pass';
$config['charset'] = 'utf-8';
$config['newline'] = "'r'n";
?>

这是我在控制器文件中的代码。

      <?php
    $msg ='';
     $msg .='<h3>Thank you for register</h3>';
      $msg .='Please follow The bellow link.';       
     $this->email->from('smit@xyz.com', 'Kayah Photography');
     $this->email->to($_POST['email']);
     $this->email->subject('Kayah Photography: Registration');
     $this->email->message($msg);
     if($this->email->send()) {
        $html ='';
        $html .= '<div class="alert alert-success" role="alert">';          
        $html .='Please check your email for details'; 
           $data['error'] = '';
           $data['success'] = $html;
           //$this->load->view('admin/new_en', $data); 
           redirect('admin/signup');
       } else { // email else
             show_error($this->email->print_debugger());
       } // email else end  
   ?> 

完成上述所有设置后,我无法解决以下错误,请任何人知道如何解决此问题。

A PHP Error was encountered
Severity: Warning
Message: fsockopen(): unable to connect to ssl://smtp.googlemail.com:465 (Connection refused)
 Filename: libraries/Email.php
 Line Number: 1689

GoDaddy 阻止其主机上的所有传出 SMTP 连接。您将不得不改用他们的SMTP中继服务器,或者使用其他主机。

http://help.godaddy.com/article/955

http://www.satollo.net/godaddy-using-smtp-external-server-on-shared-hosting