http://swiftmailer.svn.sourceforge.net/ ... 3.3.3/lib/
My international website supports 25 languages and for this reason emails need to be send using these languages.
I'm using a GMail account for sending the emails as text/html.
All looks great except for the subject line which occasionally has question marks. It seems that Swift tries to HTML encode some of the non-English characters and thus creating a wrong subject line (which should probably be plain text).
To see exactly what I mean please go to the main page of my website for collector and try either the 'Create Account' or 'Forgot Password?' features. Change the language to Spanish, for example, and try again. You will see exactly what I mean. Don't worry, my site will not save your email to spam you later.
Here's the code used (I've build a class for my mailing needs and I'm using Symfony):
Code: Select all
public static function send($mailFrom, $mailTo, $mailSubject, $mailBody) {
if (empty($mailFrom)) $mailFrom = sfConfig::get('app_email_mailer');
if (empty($mailTo)) $mailTo = sfConfig::get('app_email_mailer');
try {
// Create the mailer and message objects
$connection = new Swift_Connection_SMTP(sfConfig::get('app_email_host_addr'),
465, Swift_Connection_SMTP::ENC_SSL);
$connection->setUsername(sfConfig::get('app_email_host_user'));
$connection->setPassword(sfConfig::get('app_email_host_pwd'));
$mailer = new Swift($connection);
$message = new Swift_Message($mailSubject, $mailBody, 'text/html');
$message->setReplyTo($mailFrom);
// Send
$mailer->send($message, $mailTo, $mailFrom);
$mailer->disconnect();
} catch (Exception $e) {
throw $e;
if (isset($mailer)) $mailer->disconnect();
// handle errors here
}
}