Phpmailer Using Gmail SMTP Send From Different Sender Email

Phpmailer Using Gmail SMTP Send From Different Sender Email

Unable to Send Email From Different Email Using Gmail SMTP in Phpmailer


Friends, if you are trying to send email from gmail smtp using phpmailer and trying to sending from different sender email. And if you are unable to change sender email still displays SMTP gmail user email when your receive email. Then in the article we will find the solutions.


Lets Go
As we all know google is improving security day by day and try to protect from spammers and from spamming. Due to this different  sender email spammer were able to easily  manipulate actual sender email.

Thus google has stopped it. Any different sender email will be overridden to gmail SMTP user email. when receive.

This is below my code using different sender email.


public function programmail(){

$mail = new PHPMailer(true);

$mail->isSMTP();

$mail->Host = 'smtp.gmail.com';

$mail->SMTPAuth = true;

$mail->Username = 'ihccco***@gmail.com';

$mail->Password = '******';

//$mail->SMTPSecure = 'tls';

$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;

$mail->SMTPOptions = array( 'ssl' => array( 'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT ));

$mail->CharSet = "UTF-8";

$mail->Port = 587; //Recipients

$mail->setFrom('recruitment@i**.sa', 'IHCC');

$mail->addAddress('it3@i**.sa', 'Imran'); // Add a recipient //

$mail->addAddress('ellen@example.com'); // Name is

Comments :

Add your valuable comments, so others can read.

Leave A Comment :