"Warning: fsockopen() [function.fsockopen]: unable to connect to smtp.gmail.com:465 "
I've tried smtp.gmail.com:465, smtp.gmail.com:25, smtp.gmail.com:26, smtp.gmail.com:587, smtp.gmail.com:2525 -- no success
I've tried adding 'ssl://' to all of the above -- no success
Assume my:
gmail username: sleepydad@gmail.com
gmail password: sleepydadpassword
from: customer@yahoo.com
to: sleepydad@sleepydad.com
How would I get this code to work ... ?
Code: Select all
<?php
require_once 'lib/swift_required.php';
// create the mail transport using the 'newInstance()' method
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465)
->setUsername('myaddress@gmail.com')
->setPassword('mygmailpassword');
// create the mailer using the 'newInstance()' method
$mailer = Swift_Mailer::newInstance($transport);
// create a simple message using the 'newInstance()' method
$message = Swift_Message::newInstance()
// specify the subject of the message
->setSubject('Testing Swift Mailer')
// specify the From argument
->setFrom(array('us@yahoo.com' => 'us'))
// specify the To argument
->setTo(array('them@sbcglobal.net' =>' them'))
// specify the Cc argument
//->setCc(array('mary@domain.com' => 'Mary Jackson'))
// build the body part of the message
->setBody('Hey, how are you? I am sending you a message with the cool Swift Mailer library');
// send the email message
if ($mailer->send($message))
{
echo 'The message was sent successfully!';
}
else
{
echo 'Error sending email message';
}
?>