[thelist] PHP email problem

BT Bigpant bigpant at btinternet.com
Tue Feb 5 07:11:00 CST 2002


A couple of suggestions:

You are using stripslashes to remove \s. Are you doubling the slashes up for
\n and \r? If not, you'll only get n rather than \n. You should not need \r,
\n *should* suffice.

Instead of putting the $message in the 'message' location of the mail
function, you can leave that as "" and put the $message inside the header.
The header would look something like this:

<?
$$message = chunk_split(base64_encode($message));
$boundary = "ABC" . md5(time()) . "XYZ";

$header = "
From: \"$return_email_title\" $return_email\n
Subject: $subject\n
Date: $thedate\n
Message-ID: <abc at xyz>$return_email\n
MIME-Version: 1.0\n
Content-Type: multipart/mixed; boundary=\"$boundary\";\n
Content-Transfer-Encoding: 7bit\n
This part of the email should never be seen. If you are reading this,
consider upgrading your e-mail client to a MIME-compatible one.\n
--$boundary\n
Content-Type:text/plain; charset=\"iso-8859-1\"\n
Content-Transfer-Encoding: 7bit\n\n
$message\n\n
--$boundary\n";

mail ($recipient, $subject, "", $header);
?>

This should ensure that the MIME formatting is correct. You have much more
control over it this way than relying on the output of the mail function.

If you are still having problems, you might want to try HTML formatting the
message and use nl2br($message) to convert \n\r to <br>. You would need to
change Content-Type:text/html\n

HTH

Phil Parker



-----Original Message-----
From: thelist-admin at lists.evolt.org
[mailto:thelist-admin at lists.evolt.org]On Behalf Of Ben Phillips
Sent: 05 February 2002 11:43
To: thelist at lists.evolt.org
Subject: [thelist] PHP email problem


i am having a few issues sending mails using the PHP mail() function.

i have a textarea on a web form. the message is typed in the form, which is
passed in the $message variable.

it is then sent on using
mail($email_address,$subject,stripslashes($message),$headers)

the problem is the line spacing. on a colleague's pc, running xp and outlook
2002, there are two line returns where there should only be one. on another
pc, running windows 95 and outlook 2000, there are no line spaces at all.

i've tried regular expressions to replace the line breaks with \n \n\r and
all sorts, but i can't seem to figure out the problem. any one got any
ideas?

thanks,
benji
inchima.com

--
For unsubscribe and other options, including
the Tip Harvester and archive of thelist go to:
http://lists.evolt.org Workers of the Web, evolt !




More information about the thelist mailing list