0

I am trying to send two emails, each from a different sender. The problem is that the second email is sent from the sender of the first email. Codeigniter is ignoring the $this->email->from of the second email

$this->load->library('email');

$html="some text";

 // send email
$config['mailtype'] = 'html';
$config['protocol'] = "smtp";
$config['smtp_host'] = 'ssl://smtp.googlemail.com';
$config['smtp_user'] = 'user@gmail.com';
$config['smtp_pass'] = 'password';
$config['smtp_port'] = '465';
$config['newline'] = "\r\n";
$this->email->initialize($config);


$this->email->from('myemail@gmail.com', '');

$this->email->to("someemail@site.com");

$this->email->subject("The subject");
$this->email->message($html);

if($this->email->send()) {

}            

$this->email->clear();


$config1['mailtype'] = 'html';      
$this->email->initialize($config1);

$this->email->from('thesecondemail@www.com', 'The test');

$this->email->to("user@eee.com");
$html="Some other text";

$this->email->subject("hello some text");
$this->email->message($html);
if($this->email->send()) {

}
noufalcep
  • 3,446
  • 15
  • 33
  • 51
user3553470
  • 107
  • 9
  • did you define $config1 array ? – Owais Aslam Sep 07 '16 at 09:33
  • CI Email isn't ignoring that second `from` you have written. The reason why the delivered mail doesn't have the given from address is related with how google's smtp server works and is answered here: http://stackoverflow.com/a/1332803/2863439. – limekin Sep 07 '16 at 10:11

0 Answers0