Codeigniter电子邮件无法在服务器fsockopen()中工作:无法连接到ssl://smtp.googlemail.com:465(连接被拒绝)

问题描述 投票:0回答:2

请帮我在codeigniter电子邮件,我有很多尝试,但它没有工作,它的工作在localhost但在服务器上不起作用。

错误:

遇到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
2个回答
0
投票

您只需要从配置数组中的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
                    );

0
投票

做就是了

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
                    );

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

© www.soinside.com 2019 - 2024. All rights reserved.