I created the web application as such in the application that I need to send in order to send users their passwords if they forgot them. Now I am using a gmail account to send email. When I send an email locally from my machine using XAMPP, everything works fine and it delivers as expected. When I try to put a php script on the Hostgator server and try to send my password to the user, I cannot. But the reason I think this is happening is because Gmail will 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
Based on this letter, I would suggest that Gmail is touchy, that the host server is trying to send an email through them. My problem is that I do not know how to fix this problem (this is my first time when I do something like this). As such, I used a PHP framework called codeigniter, and here is the code used to send email (note that this code works more than fine locally, that is, I don’t think that something is 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;
}
}
Any help on this will really help, thanks
source
share