I am using the below code and I got emails but from email address not coming from setFrom()
function. Can anyone help me to set desire from email address in SMTP sendmail()
function?
include_once 'Mailer.php';
$body = 'TEST, Testing of email.';
$subject = 'Email Demo';
$email = 'test1@gmail.com';
$fromEmail = 'test2@gmail.com';
$objMail = new Mailer();
$objMail->mail->AddReplyTo('test3@gmail.com', 'Test 3');
$objMail->mail->SetFrom('testfrom1@gmail.com', 'Test From 1');
$objMail->mail->AddAddress('test4@gmail.com', 'Test 4');
$objMail->mail->IsHTML(true);
$objMail->sendmail($email, 'Test', $subject, $body);
This has been answered many times before. Gmail does not let you set arbitrary from addresses, though you can add a limited number of preconfigured aliases in your account.