Failed to send email using gmail SMTP configuration in codeigniter 3

Below is my code, and I refer to all the examples in the stack overflow guide and codeigniter. However, I cannot solve this problem.

public function send()
{
    $config['protocol'] = 'smtp';
    $config['smtp_crypto'] = 'ssl';
    $config['smtp_host'] = 'smtp.gmail.com';
    $config['smtp_port'] = '465';
    $config['smtp_user'] = '**********@gmail.com';
    $config['smtp_pass'] = '********';
    $config['mailtype'] = 'html';
    $config['charset'] = 'utf-8';
    $config['newline'] = "\r\n";
    $config['wordwrap'] = TRUE;
    $config['smtp_timeout'] = 30;
    $this->email->initialize($config);
    $this->email->from('uvizag@gmail.com', 'admin');
    $this->email->to('siddharthaesunuri@gmail.com, siddhu.php@gmail.com');
    $this->email->subject('Registration Verification:');
    $message = "Thanks for signing up! Your account has been created...!";
    $this->email->message($message);
    if ( ! $this->email->send()) {
        show_error($this->email->print_debugger());
    } 

}

How can I solve this error? may like me

+4
source share
3 answers

Are you trying to do this?

$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'xxx',
'smtp_pass' => 'xxx',
'mailtype'  => 'html', 
'charset'   => 'iso-8859-1'
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");

// Set to, from, message, etc.

$result = $this->email->send();

And make sure you have an email account Granting less secure apps access to your account

+5
source

Quỳnh Nguyễn . , , ,

$this->email->set_newline("\r\n");

gmail /​​: |

+4

I am having difficulty using this CI feature. I had to implement an external library: PHPMailer. Check out this thread .

-1
source

Source: https://habr.com/ru/post/1648126/


All Articles