我的网站在本地发送邮件,gmail,但不在服务器上。无法连接到ssl://smtp.gmail.com

时间:2016-03-02 15:47:22

标签: php codeigniter email smtp gmail

以下是send_mail()模型功能,我用它来发送电子邮件,使用'电子邮件',' subject'和'内容'消息。本地网站完全通过Gmail发送电子邮件,在托管服务器上它给我一个SMTP错误:     无法连接到ssl://smtp.gmail.com。

function send_mail( $mail, $subject, $msg )
      {
            $receiver  = $mail;
            $title = $subject;
            $sender  = "Dina";
            $sender_mail = "myemail@gmail.com";
            $message = '<html><body>';
            //$message .= "Hey $mail,<br><br>";
            $message .= $msg;
            $message .= "</body></html>";
            $ci = get_instance();
            $ci->load->library('email');
            $config['protocol'] = "smtp";
            $config['smtp_host'] = "ssl://smtp.gmail.com";
            $config['smtp_port'] = "465";
            $config['smtp_user'] = "myemail@gmail.com";
            $config['smtp_pass'] = "password";
            $config['charset'] = "utf-8";
            $config['mailtype'] = "html";
            $config['newline'] = "\r\n";
            $ci->email->initialize($config);

            $ci->email->from($sender_mail, $sender);
            $list = array($receiver);
            $ci->email->to($list);
            $this->email->reply_to('myemail@gmail.com', 'Dina');
            $ci->email->subject($title);
            $ci->email->message($message);
            // $ci->email->send();
            if(!$ci->email->send())
            {
               $this->email->print_debugger();
            }
        }

1 个答案:

答案 0 :(得分:0)

也许托管公司禁止在防火墙上使用这些端口,您是否应该问他们。