Im try to send email using gmail with codeIgniter. here is my code :
function sendemail($ 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;
}
}
My Environment is ubuntu server. Im never use postfix or sendmail. Is it required to send gmail mails ?. i double checked user name and password.!
After try send email im get this error.
您好:250-mx.google.com为您服务,[2607:5300:100:200 :: 377] 250-SIZE 35882577 250-8BITMIME 250-AUTH登录平面XOAUTH XOAUTH2 PLAIN-CLIENTTOKEN 250-ENHANCEDSTATUSCODES 250 CHUNKING
无法验证密码 . 错误:534-5.7.14请通过网络浏览器登录,然后重试 . 534-5.7.14了解更多信息,请点击534 5.7.14
来自:530-5.5.1需要认证 . 在530 5.5.1了解更多信息
遇到以下SMTP错误:530-5.5.1需要身份验证 . 了解更多资料530 5.5.1 - gsmtp to:530-5.5.1需要验证 . 在530 5.5.1了解更多信息
遇到以下SMTP错误:530-5.5.1需要身份验证 . 在530 5.5.1数据了解更多信息:530-5.5.1需要验证 . 在530 5.5.1了解更多信息
遇到以下SMTP错误:530-5.5.1需要身份验证 . 了解更多资料530 5.5.1 502 5.5.1无法识别的命令 . j4sm48430630qaf.31 - gsmtp遇到以下SMTP错误:502 5.5.1无法识别的命令 . j4sm48430630qaf.31 - gsmtp无法使用PHP SMTP发送电子邮件 . 您的服务器可能未配置为使用此方法发送邮件 .
User-Agent:CodeIgniter
日期:星期四,2014年7月3日11:20:14 0200
来自:"Asoft Administration" < ****** @ gmail.com>
返回路径:< ****** @ gmail.com>
致: ****** @ gmail.com
主题:=?utf-8?Q?Qsi_Member_confirmation_mail?=
回复:“ ****** @ gmail.com”< ****** .com>
X-Sender: ****** @ gmail.com
X-Mailer:CodeIgniter
X优先级:3(正常)
哑剧版:1.0
任何人都可以帮助我...非常感谢 .
2 回答
我有同样的问题,这是我的工作代码:
谷歌想要在第一次发送时进行授权 . 无论您是否要通过不安全的应用启用此电子邮件,Google都会向相应的电子邮件发送消息 .