简体   繁体   English

如何通过CodeGiniter中的gmail smtp发送电子邮件?

[英]how to send email through gmail smtp in codeginiter?

My site is on Godaddy hosting which have PHP version 5.4.34. 我的网站位于Godaddy托管,其PHP版本为5.4.34。 I used the codeigniters email library, I have configured the following settings in email.php under the config folder. 我使用了codeigniters电子邮件库,我在config文件夹下的email.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";
?>

Here is my code in controller file. 这是我在控制器文件中的代码。

      <?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  
   ?> 

After all the above setting I am unable to solve the following error please anybody know how to fix this. 完成上述所有设置后,我无法解决以下错误,请任何人知道如何解决。

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 blocks all outgoing SMTP connections on their hosting. GoDaddy会阻止其主机上的所有传出SMTP连接。 You will have to use their SMTP relay servers instead, or use a different host. 您将不得不使用其SMTP中继服务器,或使用其他主机。

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM