Code: Select all
function send_mail($subj, $body)
{
require("./lib/swift/Swift.php");
require("./lib/swift/Swift/Connection/SMTP.php");
$swift = new Swift(new Swift_Connection_SMTP('smtp.gmail.com',
SWIFT_SECURE_PORT,
SWIFT_TLS));
$swift->authenticate('xxxxx', 'xxxxxx');
if (!$swift->hasFailed())
{
$message =& new Swift_Message($subj, $body);
//Start a new list
$recipients =& new Swift_RecipientList();
$recipients->addTo("joe@bloggs.tld"); //or we can just add the address
$result = $swift->send($message, $recipients, new Swift_Address("xxxxxx", "xxxxx"));
if (!$result){
echo "error: ";
}
$swift->close();
}
}what do you think is going wrong?
PHP Notice: Use of undefined constant SWIFT_SECURE_PORT - assumed 'SWIFT_SECURE_PORT' in /var/www/html/parser/mls_email_utility.php on line 115
PHP Notice: Use of undefined constant SWIFT_TLS - assumed 'SWIFT_TLS' in /var/www/html/parser/mls_email_utility.php on line 116
PHP Fatal error: Uncaught exception 'Swift_Connection_Exception' with message 'The SMTP connection failed to start [smtp.gmail.com:0]: fsockopen returned Error Number 0 and Error String 'Failed to parse address "smtp.gmail.com"'' in /var/www/html/parser/lib/swift/Swift/Connection/SMTP.php:277
Stack trace:
#0 /var/www/html/parser/lib/swift/Swift.php(218): Swift_Connection_SMTP->start()
#1 /var/www/html/parser/lib/swift/Swift.php(95): Swift->connect()
#2 /var/www/html/parser/mls_email_utility.php(116): Swift->__construct(Object(Swift_Connection_SMTP))