从Hostgator服务器上托管的PHP脚本发送SMTP电子邮件 [英] Sending SMTP email from PHP Script hosted on Hostgator Servers
问题描述
我在应用程序中创建了一个Web应用程序,如果他们忘记了他们的密码,我需要发送给他们。现在我使用一个gmail帐户发送电子邮件。当我从我的机器使用XAMPP本地发送电子邮件一切工作正常,并提供如预期。当我看到把php脚本放到一个Hostgator服务器,并尝试发送用户的密码,我不能。但我认为这是因为Gmail会立即给我发送以下信息:
I have created a web application as such in the application I require to send to send users their passwords if they have forgotten them. Now I use a gmail account to send the email. When I send the email locally from my machine using XAMPP everything works fine and it delivers as expected. When I look to put the php script onto a Hostgator server and try send the user their password I can't. But the reason I think this is happening is because Gmail immediately send me the following:
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
根据此电子邮件,我假设Gmail是hostyator正试图通过他们发送电子邮件。我的问题是我不知道如何解决这个问题(这是我第一次做这样的事情)这样我使用一个称为codeigniter的PHP框架,这里是用于发送电子邮件的代码(注意这段代码工作更多比如罚款本地,即我不认为有任何错误的代码):
Based on this email I would assume that Gmail is touchy that hostgator is trying to send an email via them. My problem is I don't know how to fix this problem (This is my first time doing something like this) As such I was using a PHP framework called codeigniter and here is the code used to send the email (Note this code works more than fine locally i.e. I dont think there is anything wrong with the code):
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;
}
}
任何关于此事的帮助真的会有帮助, / p>
Any help on this matter would really help, thanks
推荐答案
它在您的Gmail设置中;您需要允许您的网站发送电子邮件;
its in your gmail settings; you need to allow your website to send emails;
要执行 https: //accounts.google.com/DisplayUnlockCaptcha ,然后点击继续;然后使用您的网站发送电子邮件电子邮件;而且Google会检测您的登录尝试并允许您。
to do so go to https://accounts.google.com/DisplayUnlockCaptcha and click continue; then useyour website to send email an email; and google will detect your login attempt and allow you.
这篇关于从Hostgator服务器上托管的PHP脚本发送SMTP电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!