Showing posts with label swiftmailer. Show all posts
Showing posts with label swiftmailer. Show all posts

Friday, April 6, 2012

trying to send mail using swift mailer, gmail smtp, php


Here is my code:




<?php
require_once 'Swift/lib/swift_required.php';

$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465)
->setUsername('me@ff.com')
->setPassword('pass');

$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance('Wonderful Subject')
->setFrom(array('me@ff.com' => 'MY NAME'))
->setTo(array('you@ss.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);
?>