【问题标题】:Codeigniter Email did not Working in Server fsockopen(): unable to connect to ssl://smtp.googlemail.com:465 (Connection refused)Codeigniter 电子邮件在服务器 fsockopen() 中不起作用:无法连接到 ssl://smtp.googlemail.com:465(连接被拒绝)
【发布时间】:2019-02-15 06:36:49
【问题描述】:

请在 codeigniter 电子邮件中帮助我, 我尝试了很多次,但没有成功, 它在本地主机上工作,但在服务器上没有工作。

错误:

遇到了 PHP 错误

严重性:警告

消息:fsockopen():无法连接到 ssl://smtp.googlemail.com:465(连接被拒绝)

文件名:libraries/Email.php

行号:2069

回溯:

文件: /home/b4ger7ik8el2/public_html/account/application/controllers/Welcome.php 行:105 功能:发送

文件:/home/b4ger7ik8el2/public_html/account/index.php 行:315 函数:require_once

$config = array(
                        'protocol' => 'smtp',
                        'smtp_host' => 'ssl://smtp.googlemail.com',
                        'smtp_port' => 465,
                        'smtp_user' => 'Email', // change it to yours
                        'smtp_pass' => 'Pasword', // change it to yours
                        'mailtype' => 'html',
                        'charset' => 'iso-8859-1',
                        'wordwrap' => TRUE
                    );

                    $message =  "
                                <html>
                                <head>
                                    <title>Verification Code</title>
                                </head>
                                <body>
                                    <h2>Thank you for Registering.</h2>
                                    <p>Dear:".$this->input->POST('firstname')."</p>
                                    <p>Email: ".$this->input->POST('user_email')."</p>
                                    <p>Please click the link below to activate your account.</p>
                                    <h4><a href='".base_url()."welcome/activate/".$email=$this->input->POST('user_email')."/'>Activate My Account</a></h4>
                                </body>
                                </html>
                                ";

                    $this->load->library('email', $config);
                    $this->email->set_newline("\r\n");
                    $this->email->from($config['smtp_user']);
                    $this->email->to($this->input->POST('user_email'));
                    $this->email->subject('Signup Verification Email');
                    $this->email->message($message);

                    //sending email
                    if($this->email->send()){
                        $this->session->set_flashdata('Success','Your Account Has Been Created Please Check your email and verify your account..!');
                    }
                    else{
                        $this->session->set_flashdata('message', $this->email->print_debugger());

                    }

【问题讨论】:

    标签: php email codeigniter-3


    【解决方案1】:

    您只需从配置数组中的 SMTP 字符串中删除 SSL 部分,

    config = array(
                   'protocol' => 'smtp',
                    'smtp_host' => 'smtp.googlemail.com',
                    'smtp_port' => 465,
                    'smtp_user' => 'Email', // change it to yours
                    'smtp_pass' => 'Pasword', // change it to yours
                    'mailtype' => 'html',
                    'charset' => 'iso-8859-1',
                    'wordwrap' => TRUE
                        );
    

    【讨论】:

    • 尝试将端口改为587并检查。
    • 你试过 print_debugger() 吗?
    • 遇到以下 SMTP 错误:111 Connection denied 无法使用 PHP SMTP 发送电子邮件。您的服务器可能未配置为使用此方法发送邮件。
    【解决方案2】:

    只是做

    config = array(
                   'protocol' => 'smtp',
                    'smtp_host' => 'smtp.googlemail.com',
                    'smtp_port' => 465,
                    'smtp_user' => 'Email', // change it to yours
                    'smtp_pass' => 'Pasword', // change it to yours
                    'mailtype' => 'html',
                    'charset' => 'iso-8859-1',
                    'wordwrap' => TRUE
                        );
    

    config = array(
                   'protocol' => 'mail',
                    'smtp_host' => 'smtp.googlemail.com',
                    'smtp_port' => 465,
                    'smtp_user' => 'Email', // change it to yours
                    'smtp_pass' => 'Pasword', // change it to yours
                    'mailtype' => 'html',
                    'charset' => 'iso-8859-1',
                    'wordwrap' => TRUE
                        );
    

    现在它肯定会为你工作。因为它对我有用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-03-13
      • 1970-01-01
      • 2017-06-08
      • 2020-12-31
      • 2012-02-21
      • 1970-01-01
      • 2016-11-07
      • 1970-01-01
      相关资源
      最近更新 更多