PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, July 6, 2022

[FIXED] How to change from email address in smtp php mailer function sendmail()

 July 06, 2022     email, php, phpmailer, smtp     No comments   

Issue

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);

Solution

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.



Answered By - Synchro
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing