When using Gmail for SMTP, can you set a different "from" address?

anon picture anon · Mar 25, 2011 · Viewed 10.8k times · Source

I am using Swift Mailer 406 for sending emails. I connect to my smtp.gmail.com account and then I do:

->setFrom(array($from => $fromname))

But the emails sent got the original gmail account email.

Can I change it?

Answer

ThiefMaster picture ThiefMaster · Mar 25, 2011

gmail doesn't allow you to use random From addresses. You have to add and validate the address you'd like to use in the gmail settings:

Settings -> Accounts -> Send mail as -> Add another email address you own