Here is my code:
setUs
GMail's SMTP requires encryption. Use:
Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, "ssl");
I got same error before and i added "ssl" parameter in Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, "ssl") like osos said.
IT WORKS!! thanks..:D
this is my code:
<?php
require_once 'swift/lib/swift_required.php';
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, "ssl")
->setUsername('XXXXXXX@gmail.com')
->setPassword('XXXXXXX');
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance('THIS IS THE SUBJECT')
->setFrom(array('XXXXXXX@gmail.com' => 'YOUR NAME'))
->setTo(array('XXXXXXX@gmail.com' => 'YOU'))
->setBody('This is the text of the mail send by Swift using SMTP transport.');
//$attachment = Swift_Attachment::newInstance(file_get_contents('path/logo.png'), 'logo.png');
//$message->attach($attachment);
$numSent = $mailer->send($message);
printf("Sent %d messages\n", $numSent);
?>