Email sending is not working after I have uploaded my source on Hosted Server , my code is given below:
function sendMail($code,$email)
{
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.gmail.com',
'smtp_port' => 465,
'smtp_user' => 'something@gmail.com',
'smtp_pass' => 'something',
'smtp_timeout' => '4',
'mailtype' => 'text',
'charset' => 'utf-8'//'iso-8859-1'
);
$message = 'Your Verification code is :'.$code;
$this->load->library('email',$config);
$this->email->set_newline("\r\n");
$this->email->from('isecvr@gmail.com',"iSec Community"); // change it to yours
$this->email->to($email);// change it to yours
$this->email->subject('Activate your account');
$this->email->message($message);
if($this->email->send())
{
return true;
}
else
{
show_error($this->email->print_debugger());
return false;
}
}
My Attempts to make this work , some worked but they are sent to Spam not on inbox, and some does not work at all:
1 - changing 'protocol' => 'sendmail'
[FAILED]
2 - changing 'smtp_host' => 'smtp.gmail.com'
or
'smtp_host' => 'ssl://smtp.gmail.com'
or
'smtp_host' => 'ssl://smtp.googlemail.com'
or
'smtp_host' => 'smtp.googlemail.com'
all [FAILED]
3 - changing 'smtp_port' => 587
or 'smtp_port' => 25
[FAILED]
4 - In my google email i have allowed Less Secure Apps
, Disabled 2 Step Verification
[FAILED]
5 - Commenting/removing $config
variable [SUCCESS] but email is sent to SPAMS with following warning with yellow background
This message may not have been sent by: isecvr@gmail.com
Kindly Suggest me what should i do , i am trying to send email for now more than 10 hours now.