Page 1 of 1

Weird problem

Posted: Wed Apr 02, 2008 3:42 am
by Lars Boldt
I've got a weird problem when sending HTML e-mails...

Before the mail is passed to SWIFT, everything is ok, but when I receive it, randomly, "! " (exclamation mark + space), is inserted in the HTML code. Sometimes I get it for instance in a style tag, PADDING-TOP! :10px, other times in the middle of a word "f! oo".

I've asked my hosting company (where our mail passes through) if any filters (spam or whatever else) could cause this problem to which they responded that is was very unlikely that their email server caused this problem.

It's not the email app either cause I tested the email in an webmail solution and it had the same problem, albeit on the same server.

My question is, could SWIFT cause this?

Re: Weird problem

Posted: Wed Apr 02, 2008 7:22 am
by Chris Corbyn
Are you the same person who emailed me earlier? No worries if not; it's just this would be a weird coincidence.

Re: Weird problem

Posted: Wed Apr 02, 2008 7:25 am
by Chris Corbyn
My answer to the guy who asked earlier was that it sounds like an incorrect character encoding being specified. Make sure you're specifying the charset when you're using Swift. Swift itself wouldn't do this no, especially not if you're seeing the issue in separate apps.

You can see what Swift is about to send by calling this:

Code: Select all

$stream =& $message->build();
echo $stream->readFull();
You'll want to use "View Source" in your browser to correctly see the email source.

Re: Weird problem

Posted: Wed Apr 02, 2008 7:34 am
by Lars Boldt
Hi Chris, I don't believe i've specified an encoding, i'll look into that ASAP.

And no, I didn't email you, as far as I know anyway hehe.

Re: Weird problem

Posted: Wed Apr 02, 2008 7:37 am
by Chris Corbyn
Lars Boldt wrote:Hi Chris, I don't believe i've specified an encoding, i'll look into that ASAP.

And no, I didn't email you, as far as I know anyway hehe.
I don't stress it in my documentation. I really want rock-solid documentation with v4. Heh, I'm even writing a proper e-book for it.

Re: Weird problem

Posted: Wed Apr 02, 2008 8:13 am
by Lars Boldt

Code: Select all

 
To:
From:
Subject: test
Date: Wed, 02 Apr 2008 15:08:00 +0200
X-LibVersion: 3.3.2
MIME-Version: 1.0
Content-Type: multipart/alternative;
 boundary="_=_swift-200458016047f38530e55be8.83946559_=_"
Content-Transfer-Encoding: 7bit
 
This is a message in multipart MIME format.  Your mail client should not
be displaying this. Consider upgrading your mail client to view this
message correctly.
--_=_swift-200458016047f38530e55be8.83946559_=_
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
 
I'm still getting the "error" after specifiying charset / encoding like this:

Code: Select all

 
$message->attach(new Swift_Message_Part($plainTextMsg, "text/plain", "8bit", "utf-8"));
$message->attach(new Swift_Message_Part($messageData, "text/html", "8bit", "utf-8"));
 
I did $message->build() and echoed the data and it was not present in what was displayed...

Any ideas?

Re: Weird problem

Posted: Wed Apr 02, 2008 8:33 am
by Lars Boldt
Upon further testing it seems it is the data coming from mySQL which causes the problem, when it is present in the mail, the "error" can occur in both the mySQL data and/or in the data added directly from code.

If the mySQL data is removed, the error doesn't occur. Furthermore, it doesn't seem it is as random as first thought. If the HTML is inserted into mySQL through IE the error occur in one specific place. If using FF the error occur in another specific place. You can't see the error until it's in your mailbox however heh.

The webpage use UTF-8, the database use UTF-8 and now the mail is sent as UTF-8.

Thoughts?

Re: Weird problem

Posted: Thu Apr 03, 2008 6:27 am
by Chris Corbyn
Is anything being copied and pasted from an application such as MS Word somewhere along the way? The fact the issue is occurring when crossing a boundary between a browser and the server or MySQL and PHP really does suggest that although you are using UTF-8, there's something non-UTF-8 corrupting the data. There will be a mail server somewhere between Swift and the receiver which is seeing an unexpected octet in the UTF-8 stream and replacing it with ! (like some browsers replace wonky characters with ?)