I'm using codeigniter 2.1.4 to send email using gmail's smtp. Here is my config:
$config['protocol'] = 'smtp';
$config['smtp_crypto'] = 'ssl';
$config['smtp_host'] = 'smtp.gmail.com';
$config['smtp_user'] = 'myaccount@gmail.com';
$config['smtp_pass'] = 'my secret password';
$config['smtp_port'] = '465';
$config['newline'] = "\r\n";
$this->load->library('email', $config);
$this->email->from('xxxxxxx', '');
$this->email->to('johndoe@gmail.com');
$this->email->subject(' CodeIgniter Rocks Socks ');
$this->email->message('Hello World');
I wonder $this->email->from('xxxxxxx', ''); if I should always put myaccount@gmail.com (same as the username that I use for the smtp user field. I wonder if I can change it to something like something@server-hostname.
Also I want to know if I need to set the account permission (https://support.google.com/accounts/answer/3466521) before using this gmail smtp. I found out that there are times that I can't send email using the exact same configuration. I have to resend it few times (each time it will generate the gmail authentication failed error). then I have to login to my myaccount@gmail.com (smtp username) account's recent activity page (https://support.google.com/mail/answer/45938?hl=en) and remove the unusual activity. Once I have removed the unusual activity then I can send email without any error.