Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set 'FROM' property using Swiftmailer with Gmail?

<?php
require_once 'lib/swift_required.php';
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl')
  ->setUsername('[email protected]')
  ->setPassword('password')
  ;
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance('HomeWork')
  ->setFrom(array('[email protected]' => 'NAME'))
  ->setTo(array('[email protected]'=> 'NAME'))
  ->setBody('Test Message Body')
  ;
$mailer->send($message);
?>

It works but sender is '[email protected]'. How can I specify any other email address in order to send fake email?

like image 395
Giorgi Cxondia Avatar asked Jan 02 '13 20:01

Giorgi Cxondia


Video Answer


1 Answers

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.

like image 160
Zevi Sternlicht Avatar answered Sep 25 '22 19:09

Zevi Sternlicht