沃梦达 / 编程问答 / php问题 / 正文

无法在 codeigniter 3 中使用 SMTP gmail 配置发送电子邮件

Unable to send email using SMTP gmail config in codeigniter 3(无法在 codeigniter 3 中使用 SMTP gmail 配置发送电子邮件)

本文介绍了无法在 codeigniter 3 中使用 SMTP gmail 配置发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我的代码,我参考了堆栈溢出和 codeigniter 用户指南中的所有示例.我仍然无法解决这个问题

Below are my code and I refer all examples in stack overflow and codeigniter user guide. still I unable to solve this

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'] = "
";
    $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 ? could please favor to me

推荐答案

你试试这个吗?

$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("
");

// Set to, from, message, etc.

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

并确保您已将电子邮件帐户设置为允许不太安全的应用访问您的帐户

And make sure you had setting your email account with Allowing less secure apps to access your account

这篇关于无法在 codeigniter 3 中使用 SMTP gmail 配置发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:无法在 codeigniter 3 中使用 SMTP gmail 配置发送电子邮件

基础教程推荐