无法发送谷歌邮件CodeIgniter与ubuntu服务器


Unable to send google mail CodeIgniter with ubuntu server

我尝试使用gmail与codeIgniter发送电子邮件。下面是我的代码:

函数sendmail ($name,$key, $email) {

    $this -> load -> library('email');      
    $econfig['protocol'] = "smtp";
    $econfig['smtp_host'] = "ssl://smtp.googlemail.com";
    $econfig['smtp_port'] = 465;
    $econfig['smtp_user'] = "*******@gmail.com"; 
    $econfig['smtp_pass'] = "******";
    $econfig['charset'] = "utf-8";
    $econfig['mailtype'] = "html";
    $this -> email -> initialize($econfig);
    $this->email->set_newline("'r'n");
    $this -> email -> from('*********@gmail.com', 'Asoft Administration');
    $this -> email -> to($email);
    $this -> email -> subject('Subject');
    $this -> email -> message("HTML MESSAGE");
    if (!$this -> email -> send()) {
        echo $this -> email -> print_debugger();
        return false;
    } else {            
        return true;
    }
}

我的环境是ubuntu服务器。我从不使用后缀或sendmail。需要发送gmail邮件吗?我仔细检查了用户名和密码。

在尝试发送电子邮件后,我得到这个错误。

[2607:530:100:200::377]尺寸250 - 35882577250 - 8 bitmime250认证登录plain xoauth xoauth2 plain - clienttoken250 - enhancedstatuscodes250年分块

验证密码失败。错误:534-5.7.14请通过web浏览器登录,然后再试一次。534-5.7.14点击534 5.7.14了解更多

from: 530-5.5.1 Authentication Required。欲知详情,请浏览530年5.5.1

遇到以下SMTP错误:530-5.5.1 Authentication Required。了解更多在530 5.5.1 - gsmtpto: 530-5.5.1需要鉴权。欲知详情,请浏览5.5.1

遇到以下SMTP错误:530-5.5.1 Authentication Required。详见530 5.5.1数据:530-5.5.1鉴权要求。欲知详情,请浏览5.5.1

遇到以下SMTP错误:530-5.5.1 Authentication Required。详见530 5.5.1502 5.5.1无法识别的命令。j4sm48430630qaf。31 - GSMTP遇到以下SMTP错误:502 5.5.1命令不可识别。j4sm48430630qaf。31 - GSMTP无法使用PHP SMTP发送电子邮件。您的服务器可能没有配置为使用此方法发送邮件。

user - agent: CodeIgniter

日期:Thu, 3 Jul 2014 11:20:14 +0200

:"Asoft政府"& lt; * * @gmail.com>

网络:& lt; * * @gmail.com>

: * * @gmail.com

主题:= utf - 8 ?问? Qsi_Member_confirmation_mail吗?=

应答:" * * @gmail.com"& lt; * * 网络>

X-Sender: * * @gmail.com

X-Mailer: CodeIgniter

X-Priority: 3 (Normal)

问题:& lt; 53 b5204ed3324@gmail.com>

Mime-Version: 1.0

任何人都可以帮助我…由于很多。

我有同样的问题,这是我的工作代码:

$config = array(
    'protocol' => 'smtp',
    'smtp_host' => 'ssl://smtp.googlemail.com',
    'smtp_port' => 465,
    'smtp_user' => 'my@gmail.com',
    'smtp_pass' => 'xxx',
    'mailtype' => 'html',
    'charset' => 'iso-8859-1',
    'wordwrap' => TRUE
);
$this->load->library('email', $config);
$this->email->set_newline("'r'n");
$this->email->from('my@gmail.com', 'Niraj');
$this->email->to($email);
$this->email->subject('SOME SUBJECT');
$this->email->message('<p>Some Content</p>');
$this->email->send();

Google希望在第一次尝试发送时进行授权。谷歌发送消息到相应的电子邮件,您是否想启用使用此电子邮件通过不安全的应用程序。