[FIXED] Disabling "auto UTF8 everything"
Moderators: Chris Corbyn, General Moderators
[FIXED] Disabling "auto UTF8 everything"
Migrating from 2.x to 3.x has proven to be a breeze, with one major exception, the annoying desire by 3.x to "do all things UTF-8". I cannot for the life of me figure out where I go wrong, but the two most common mailers I use here (our company's webmail and Thunderbird) have serious problems reading the messages generated.
I have tried forcing the isUTF8() to return false, but it manages to end up as utf-8 anyway. Or, more correctly, SM inserts information to that effect, regardless of my settings, content, and what not.
I want to force ALL attachments to base64 encoding
I want to force ALL (other) content to be iso-8859-1, quoted-printable
(including headers)
I've had varying levels of success when testing .. I've changed the filenames for the attachments to only contain ASCII characters, in which case it works fine, I've removed swedish national (iso-8859-1) characters from the subject line, and that got rid of the ???utf8??? encoding of the subject line (which Thunderbird displays as a single ? character).
But these sort of workarounds should not be necessary ... aaaargh!
I'm sure I'm doing something wrong, but I can't figure out what that would be.
-joho
I have tried forcing the isUTF8() to return false, but it manages to end up as utf-8 anyway. Or, more correctly, SM inserts information to that effect, regardless of my settings, content, and what not.
I want to force ALL attachments to base64 encoding
I want to force ALL (other) content to be iso-8859-1, quoted-printable
(including headers)
I've had varying levels of success when testing .. I've changed the filenames for the attachments to only contain ASCII characters, in which case it works fine, I've removed swedish national (iso-8859-1) characters from the subject line, and that got rid of the ???utf8??? encoding of the subject line (which Thunderbird displays as a single ? character).
But these sort of workarounds should not be necessary ... aaaargh!
I'm sure I'm doing something wrong, but I can't figure out what that would be.
-joho
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Are you using "Swift" or "EasySwift" ?
Just about to take a closer look at what you're saying now... the UTF-8 should only kick in if it sees UTF-8 byte sequences in the string, so something mustn't working correctly there if you're sending iso-8859-1.
* Attachments are base64 encoded by default (I'll never change that), but you can change it:
* To force character sets and encodings in headers:
Like I say, about to take a closer look at this now 
Just about to take a closer look at what you're saying now... the UTF-8 should only kick in if it sees UTF-8 byte sequences in the string, so something mustn't working correctly there if you're sending iso-8859-1.
* Attachments are base64 encoded by default (I'll never change that), but you can change it:
Code: Select all
$att = new Swift_Message_Attachment($data, $filename, $type, "quoted-printable");
//or
$att = new Swift_Message_Attachment($data, $filename);
$att->setEncoding("quoted-printable");Code: Select all
$message->headers->setEncoding("QP");
$message->headers->setCharset("iso-88591");
//and for parts
$part->headers->setEncoding("QP");
$part->headers->setCharset("iso-88591");
//and for attachments
$att->headers->setEncoding("QP");
//you get the idea...feyd | Please use
In other words, I had to leave the constructor call void of parameters, and then do them in the above order. So with the exception of the "screwed up" (?) last attachment, it's now doing what I want it to do.
To get the message header generated like I wanted to, I had to do it like above, i.e. call the constructor for the message void of any parameters, then set the charset to iso-8859-1, and then start passing it data.
-joho
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I was using EasySwift, and abandoned that idea after three hours of searching.
I'm now down to having it work, almost; the last attachment in a series of three is not recognized by some mailer clients. The attachments are all generated in the same fashion (in the same loop in the code). But, I had to do it this way to get it to do what I wanted:Code: Select all
$sa =& new Swift_Message_Attachment ();
$sa->headers->language = 'sv';
$sa->headers->setCharset ('iso-8859-1');
$sa->setFilename ($xfn);
$sa->setData ($xa);
$sa->setContentType ('application/pdf');
$sm->attach ($sa);To get the message header generated like I wanted to, I had to do it like above, i.e. call the constructor for the message void of any parameters, then set the charset to iso-8859-1, and then start passing it data.
-joho
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
I've made changes by including a setLanguage() method and by making iso-8859-1 the default charset just like it is for the body. UTF-8 will be detected only if it's there.
I won't be releasing this until tomorrow, but it's in subversion now.
EDIT | I'm also thinking of making a Swift_Message_Defaults class to set the global defaults yourself, rather than having Swift decide so intrusively.
I won't be releasing this until tomorrow, but it's in subversion now.
EDIT | I'm also thinking of making a Swift_Message_Defaults class to set the global defaults yourself, rather than having Swift decide so intrusively.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia