Take the 2-minute tour ×
require_once 'lib/swift_required.php';
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl')
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance('HomeWork')
  ->setFrom(array('exampleFROM@gmail.com' => 'NAME'))
  ->setTo(array('exampleTO@gmail.com'=> 'NAME'))
  ->setBody('Test Message Body')

It works but sender is 'username@gmail.com'. How can I specify any other email address in order to send fake email?

share|improve this question

2 Answers 2

Gmail disallows overriding the FROM name except from verfied email addresses that you prove to gmail you own. Either choose a different email server or go to your gmail settings and change it to another valid email address that you can receive email from.

share|improve this answer

You need to set the outgoing emailaddress in gmail. Gmail changes the emailaddress to the address in your gmail if it is not in the list of emailaddresses where you can sent from.

Gmail -> settings -> Send mail as -> Add another email address you own

share|improve this answer
Perhaps using a reply-to could accomplish OP's needs? –  ficuscr Jan 2 '13 at 20:14
No, gmail removes the reply-to headers. –  John Jan 2 '13 at 20:16
I added my another email, but it doesn't work. Original sender's address is still visible. –  Giorgi Cxondia Jan 2 '13 at 20:35

Your Answer


