Swift Mailer...
Posted: Mon Jun 19, 2006 2:36 pm
I've downloaded the latest Swift Mailer (Swift-1.2.2.zip) and created a function to use across my site.
php version: PHP 4.4.1
Function:
Tried:
Output:
php version: PHP 4.4.1
Function:
Code: Select all
function swiftmailer($username, $email, $subject, $message, $members)
{
$members = ($members == 0) ? 'members' : '';
require($members . '/includes/swift_mailer/Swift.php');
require($members . '/includes/swift_mailer/Swift_SMTP_Connection.php');
$connection = new Swift_SMTP_Connection('mail.blah.com');
$mailer = new Swift($connection, $_SERVER['SERVER_NAME']);
//If anything goes wrong you can see what happened in the logs
if (!$mailer->hasFailed())
{
$mailer->addPart($message, 'text/html');
$mailer->send(
'"' . $username . '" <' . $email . '>',
'"NO REPLY" <blah@blah.com>',
$subject
);
$mailer->close();
$emaillog = '<br>Successfully sent email.<br>';
}
else
{
$emaillog = '<br>Unsuccessfully sent email.<br>';
}
//echo all for debugging
echo $emaillog;
echo $swiftwerror = "The mailer failed to connect. Errors: ".print_r($mailer->errors, 1).". Log: ".print_r($mailer->transactions, 1);
}Tried:
Code: Select all
swiftmailer('blahh', 'my@email.com', 'subject', 'body', 0);Parse error: parse error, unexpected T_STRING in /home/blah/public_html/members/includes/swift_mailer/Swift.php on line 65