简体   繁体   English

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

[英]My website sends mail ,gmail, locally but not on server. Unable to connect to ssl://smtp.gmail.com

The following is the send_mail() model function that I use to send emails using the 'email', 'subject', and 'content' of message. 以下是send_mail()模型函数,我使用该函数使用消息的“电子邮件”,“主题”和“内容”发送电子邮件。 Locally the website sends emails through gmail perfectly yet, on the hosting server it gives me an SMTP error: unable to connect to ssl://smtp.gmail.com . 该网站在本地完美地通过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();
            }
        }

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

暂无
暂无

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

相关问题 Connection could not be established with host smtp.gmail.com:stream_socket_client(): unable to connect to ssl://smtp.gmail.com:465 - Connection could not be established with host smtp.gmail.com :stream_socket_client(): unable to connect to ssl://smtp.gmail.com:465 在Codeigniter中无法发送电子邮件-fsockopen():无法连接到ssl://smtp.gmail.com:465(连接被拒绝) - in Codeigniter Unable to send email - fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (Connection refused) 消息:fsockopen():无法连接到ssl://smtp.gmail.com:465(连接超时) - Message: fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (Connection timed out) CodeIgniter电子邮件:fsockopen():无法连接到ssl://smtp.gmail.com托管中 - CodeIgniter email: fsockopen(): Unable to connect to ssl: //smtp.gmail.com in hosting 如何解决错误:消息:fsockopen():无法连接到 ssl://smtp.gmail.com:465(连接被拒绝) - How to resolve the error: Message: fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (Connection refused) [SMTP:无法连接套接字:fsockopen():无法连接至ssl://smtp.gmail.com:465(未知错误)(代码:-1,响应:)] - [SMTP: Failed to connect socket: fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (Unknown error) (code: -1, response: )] 无法在 Django 中连接到 smtp.gmail.com - Can not connect to smtp.gmail.com in Django 连接失败。 错误 #2:stream_socket_client():无法连接到 ssl://smtp.gmail.com:465(连接被拒绝) - Connection failed. Error #2: stream_socket_client(): unable to connect to ssl://smtp.gmail.com:465 (Connection refused) 发送通过smtp.gmail.com连接的php邮件 - send php mail connecting through smtp.gmail.com PHPMailer错误使用smtp.gmail.com发送邮件 - PHPMailer error sending mail with smtp.gmail.com
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM