I'm trying to use PHP Pear Factory to send emails through GMail in one project. It has been successful, but there is something that is not working 100% properly.
I don't know why if I set $headers['From'] = 'from@domain.com'
, when I receive the email the From is username@gmail.com.
Find below the code:
$recipients = 'to@domain.com';
$headers['From'] = 'from@domain.com';
$headers['To'] = 'to@domain.com';
$headers['Subject'] = 'Test message';
$body = 'Test message';
$params["host"] = 'ssl://smtp.gmail.com';
$params["port"] = 465;
$params["auth"] = true;
$params["username"] = 'username@gmail.com';
$params["password"] = 'password';
// Create the mail object using the Mail::factory method
$mail_object =& Mail::factory('smtp', $params);
$send = $mail_object->send($recipients, $headers, $body);
if(PEAR::isError($send)) { print($send->getMessage()); }