Электронная почта Codeigniter не работает на сервере fsockopen (): невозможно подключиться к ssl: //smtp.googlemail.com: 465 (соединение отклонено) - PullRequest
0 голосов
/ 15 февраля 2019

Пожалуйста, помогите мне в codeigniter Email, у меня было много попыток, но это не сработало, Оно работает на локальном хосте, но не работает на сервере.

ОШИБКА:

PHPОбнаружена ошибка

Серьезность: Предупреждение

Сообщение: fsockopen (): невозможно подключиться к ssl: //smtp.googlemail.com: 465 (соединение отклонено)

Имя файла: library / Email.php

Номер строки: 2069

Backtrace:

Файл: /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());

                    }

Ответы [ 2 ]

0 голосов
/ 11 июня 2019

просто сделайте

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

Теперь это наверняка будет работать для вас.Как это у меня сработало.

0 голосов
/ 15 февраля 2019

Вам просто нужно удалить часть SSL из строки SMTP в массиве конфигурации,

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
                    );
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...