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

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?


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