Page 1 of 1

strange mail issue

Posted: Wed Oct 07, 2009 2:07 pm
by desperado
I have the following:

Code: Select all

 
$emailmessage = "
<html>
<head>
<title>Contact Page Request</title>
</head>
<body>";
if (isset($_POST['request1'])) {
$emailmessage .= "<p><font size='2' face='Arial, Helvetica, sans-serif'>Someone requested a quote for the following: </font></p>
  <p><font size='2' face='Arial, Helvetica, sans-serif'>Request: $_POST[quote_client_comment]</p>
  <p><font size='2' face='Arial, Helvetica, sans-serif'>You can generate the quote here: 
<a href='http://****************************************.php?recordID=$quote_id'>CLICK HERE</a></p>
 </body>
</html>
";
 
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
$headers .= 'Content-Transfer-Encoding: quoted-printable' . "\r\n";
 
When the email is received and viewed, we see this:
...quote_init.php?recordID#363

while the raw source of the email shows properly:
...quote_init.php?recordID=23363

I'm stumped. I've seen somewhere that # has a hex equivalent of 23, but 8O

any help would be appreciated.

Re: strange mail issue

Posted: Wed Oct 07, 2009 2:15 pm
by requinix
You've seen things like %23 in a URL, right? It's a way of representing a literal '#' without having any special meaning like a # normally does.
The quoted-printable transfer encoding is the same, except is uses a '=' instead of a '%'. Thus when you put a

Code: Select all

=23
in your quoted-printable message you're really putting in an encoded '#'.

Unless you're actually sending UTF-8 data (doesn't look like you are) use the US-ASCII character set and the 7bit transfer encoding.

Re: strange mail issue

Posted: Wed Oct 07, 2009 2:22 pm
by desperado
Thanks! I figured it had to do with the headers.

I do use accented characters pulled from a DB, so that's why I use UTF-8.

Re: strange mail issue

Posted: Wed Oct 07, 2009 2:31 pm
by desperado
Question. Can I use default 7 bit encoding with UTF-8?

Thx

Re: strange mail issue

Posted: Wed Oct 07, 2009 3:01 pm
by requinix
No, not really. 7bit means that each character should have the eighth bit as zero, but that doesn't happen with UTF-8. There is an 8bit encoding but it's not handled everywhere: quoted-printable is best.

I think mail() will handle all the dirty work for you, with regards to transfer encoding and the like. Send yourself an email (with only the Content-Type specified in your code) and see what the headers are.

Re: strange mail issue

Posted: Thu Oct 08, 2009 10:11 am
by desperado
I removed the transfer encoding and it worked fine.

I thought that if it was not specified, it would default to 7-bit, but you are right, mail() handled it all pretty.

Thanks tasairis.