Code: Select all
<php
require("swift/Swift.php");
require("swift/Swift/Connection/SMTP.php");
$smtp = new Swift_Connection_SMTP('smtp.gmail.com',
Swift_Connection_SMTP::PORT_SECURE,
Swift_Connection_SMTP::ENC_TLS);
$smtp->setUsername("xxxxx@gmail.com");
$smtp->setPassword("xxxxxx");
$swift = new Swift($smtp);
$message = new Swift_Message("subject", "body");
//Start a new list
//$recipients = new Swift_RecipientList();
//$recipients->addTo("xxxxxxx@hotmail.com"); //or we can just add the address
$result = $swift->send($message, $recipients, new Swift_Address("xxxxxxxx@hotmail.com", "Hector Scout"));
if (!$result){
echo "error: ";
}
$swift->disconnect();
?>I'm getting this error:
Fatal error: Uncaught exception 'Swift_Connection_Exception' with message 'The SMTP connection failed to start [tls://smtp.gmail.com:465]: fsockopen returned Error Number 40 and Error String 'Unable to find the socket transport "tls" - did you forget to enable it when you configured PHP?'' in C:\Program Files\php\PEAR\swift\Swift\Connection\SMTP.php:291 Stack trace: #0 C:\Program Files\php\PEAR\swift\Swift.php(220): Swift_Connection_SMTP->start() #1 C:\Program Files\php\PEAR\swift\Swift.php(97): Swift->connect() #2 D:\www\sendEmail.php(37): Swift->__construct(Object(Swift_Connection_SMTP)) #3 {main} thrown in C:\Program Files\php\PEAR\swift\Swift\Connection\SMTP.php on line 291
Any help?