use*_*610 5 php email gmail codeigniter
我已经在我需要发送的应用程序中创建了一个Web应用程序,以便在忘记密码时向用户发送密码.现在我使用Gmail帐户发送电子邮件.当我使用XAMPP从我的机器本地发送电子邮件时,一切正常,它按预期交付.当我想把php脚本放到Hostgator服务器上并尝试向用户发送他们的密码我不能.但我认为这种情况发生的原因是因为Gmail立即向我发送以下信息:
Someone recently used your password to try to sign in to your Google Account myemail@gmail.com. This person was using an application such as an email client or mobile device.
We prevented the sign-in attempt in case this was a hijacker trying to access your account. Please review the details of the sign-in attempt:
Tuesday, January 21, 2014 1:42:56 PM UTC
IP Address: 198.57.247.245 (gator3281.hostgator.com.)
Location: Los Angeles, CA, USA
If you do not recognize this sign-in attempt, someone else might be trying to access your account. You should sign in to your account and reset your password immediately
Run Code Online (Sandbox Code Playgroud)
根据这封电子邮件,我认为Gmail很容易让hostgator试图通过它们发送电子邮件.我的问题是我不知道如何解决这个问题(这是我第一次做这样的事情)因此我使用的是一个名为codeigniter的PHP框架,这里是用来发送电子邮件的代码(注意这段代码更多比当地好,即我不认为代码有任何问题):
public function SendEmailValidate($email,$subject,$message,$type)
{
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'myemail@gmail.com',
'smtp_pass' => 'mypassword',
'smtp_timeout' => 30,
'mailtype' => $type
);
$CI = &get_instance();
$CI->load->library('email',$config);
$CI->email->set_newline("\r\n");
$CI->email->from('myemail@gmail.com','Book Bay');
$CI->email->to($email);
$CI->email->subject($subject);
$CI->email->message($message);
if($CI->email->send())
{
return true;
}
else
{
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
对此事的任何帮助都会有所帮助,谢谢
它在你的Gmail设置中; 你需要允许你的网站发送电子邮件;
要执行此操作,请访问https://accounts.google.com/DisplayUnlockCaptcha并单击"继续"; 然后使用您的网站发送电子邮件; 谷歌将检测您的登录尝试并允许您.
| 归档时间: |
|
| 查看次数: |
10576 次 |
| 最近记录: |