Search code examples
emailsmtpgmailphpmailer

Removing 'gmail.com' from the 'from' when using gmail smtp and phpmailer


I am using PhpMailer to send emails via gmail smtp. And while $mail->setFrom('[email protected]','Jack Schmitt'); does insert 'Jack Schmitt' as the name of the sender, it is still including my smtp username. So the recipient will see something like this: Jack Schmitt<[email protected]> in the From: line

Is there a way to have it say Jack Schmitt<[email protected]> in stead?


Solution

  • You can't send using arbitrary from addresses, because that would usually be forgery. You can only send from your account address or predefined (in gmail settings) aliases. This is a gmail feature covered in their docs.