Page 1 of 1

Problem with recipients name and special chars

Posted: Tue May 13, 2008 8:59 am
by marzim
First, thanks for an excellent library.

Now to my question. I'm trying the following:

Code: Select all

 
$addressbook_name = "Test: Testing";
$addressbook_email = "test@example.com";
 
$recipients->addTo(utf8_decode($addressbook_email),utf8_decode($addressbook_name);
 
$swift->attachPlugin(new Swift_Plugin_Decorator(new Replacements()), "decorator");
$swift->batchSend($message, $recipients, $sender);
 
 
But when the e-mail is sent its translates to Test:@sendingdomain.com:Testing <test@example.com> in some strange way.

Anyone have any ideas what goes wrong?

I'm using Swift Library 3.3.2 and PHP5

Thanks,
Martin

Re: Problem with recipients name and special chars

Posted: Tue May 13, 2008 5:22 pm
by Chris Corbyn
What do the input strings look like to produce that output?

Re: Problem with recipients name and special chars

Posted: Tue May 13, 2008 6:09 pm
by marzim
This is my input: (or did I missunderstand you?)

Code: Select all

 
$addressbook_name = "Test: Testing";
$addressbook_email = "test@example.com";
 
And I'm sure it the specialchar : that is causing the problem. Everything else works perfect and if I remove the special char it's back to normal again.

Re: Problem with recipients name and special chars

Posted: Tue May 13, 2008 10:21 pm
by Chris Corbyn
Hmm... This probably is a bug in version 3 yes.

Just made sure it doesn't break in version 4 and indeed it doesn't. That's my fault for a lack of interpretation of the RFC when writing v3.

It needs a backslash (which Swift should add, and does add in v4).

This code:

Code: Select all

$message = Swift_Message::newInstance()
  ->setSubject('A basic message')
  ->setTo(array('chris.corbyn@swiftmailer.org' => 'Test: Testing'))
  ->setFrom(array('chris@w3style.co.uk' => 'Myself'))
  ->setContentType('text/plain')
  ->setCharset('utf-8')
  ->setBody('just testing')
  ;
Produces this output for me:

Code: Select all

Message-ID: <1210734742.482a5896c55b3@swift.generated>
Date: Wed, 14 May 2008 13:12:22 +1000
Subject: A basic message
From: Myself <chris@w3style.co.uk>
To: "Test\: Testing" <chris.corbyn@swiftmailer.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
 
just testing
Are you doing anything intensive or complex with Swift? You can use version 4 in it's alpha if you want to? I'd show you how to change the code.

Re: Problem with recipients name and special chars

Posted: Fri May 16, 2008 4:53 am
by marzim
Thanks for your replay, Chris. Indeed, it seems like a bug.

A change to the new version when it's still in alpha isn't an option. We are using Swift for sending out all of our customer’s newsletters.

How far away is a stable release? Maybe it’s best to fix it temporarily in the version I’m using. Do you have any idea where I should look for the code to change?

My best guess is in the function getEncoded($name) in Swift/Message/Headers.php at line 369.