BUG? Question marks in email subject for non-English

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
colnector
Forum Newbie
Posts: 9
Joined: Thu Nov 06, 2008 1:30 am

BUG? Question marks in email subject for non-English

Post by colnector »

First, Swift Mailer is really easy to use and performs very well so far. I'm using the svn version from:
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
        }   
  }
Many thanks in advance
andyb
Forum Newbie
Posts: 12
Joined: Tue Feb 05, 2008 3:39 am

Re: BUG? Question marks in email subject for non-English

Post by andyb »

Please see response in another thread I just replied in, current version of SWIFT has encoding issues with the Subject.
colnector
Forum Newbie
Posts: 9
Joined: Thu Nov 06, 2008 1:30 am

Re: BUG? Question marks in email subject for non-English

Post by colnector »

I've just checked theother thread. Too bad :(
andyb
Forum Newbie
Posts: 12
Joined: Tue Feb 05, 2008 3:39 am

Re: BUG? Question marks in email subject for non-English

Post by andyb »

Just to let everyone know, although a supporter of Swiftmail, the lack of support recently has led me to look for other solutions due to some urgent demands.

I have come across a mail class called Nomad. Quite simply it works, where Swiftmail and PHPMailer fail, this works. I can send different languages in utf-8 including embedded images, have Russian text in From and Subject fields and it works!

I hope Chris the Developer of Swiftmail comes back online soon, but in the meantime give Nomad a try!
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: BUG? Question marks in email subject for non-English

Post by Chris Corbyn »

Sorry about that. All of the encoding bugs have been fixed in version 4 since it's character set aware.

Thanks for pointing out Nomad, I'll have to take a look over the source since I wasn't aware it even existed ;)
Post Reply