Plain Text Email Problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
patch2112
Forum Commoner
Posts: 86
Joined: Sun Oct 31, 2004 9:44 am
Location: London

Plain Text Email Problem

Post by patch2112 »

Hello all, I'm going to be bald soon if I don't figure this out!!!

I'm sending a plain text email. There is a section in the code that does the following...

Code: Select all

if ($mail == "client") { $msg .= "Quantity: $row_2[2] - Colour: $row_2[1] - Size: $row_2[0]\r"; }
if ($mail == "brigade") { $msg .= "Stock Quantity: $row_2[2] - Colour: $row_2[1] - Size: $row_2[0]\r"; }
But the second option doesn't include a carriage return. If I put "\r\r" in, then I get 2. I've also tried all sorts of moving things around, trying "\n's" and so forth. Even tried adding the "\r" after this branch and still have the same problem.

It seems to be a length issue, as I can delete "Stock" from the second option, put it in the first, and the problem is reversed.

Any ideas?
Philip
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Try only using "\n"s.
patch2112
Forum Commoner
Posts: 86
Joined: Sun Oct 31, 2004 9:44 am
Location: London

ty

Post by patch2112 »

Thanks abush,

Same problem though...

Philip
User avatar
ok
Forum Contributor
Posts: 393
Joined: Wed May 31, 2006 9:20 am
Location: The Holy Land

Post by ok »

1. Try the PHP Swift Mailer: viewtopic.php?t=48055.
2. You can use HTML mail instead. Remeber to add these headers:

Code: Select all

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
3. Anyway, if you want to use a simple mail, single "\n" should do the job!!! (You can check the PHP manual - mail() - Example 1. Sending mail)
patch2112
Forum Commoner
Posts: 86
Joined: Sun Oct 31, 2004 9:44 am
Location: London

No good

Post by patch2112 »

Thanks OK, but still no dice.

I have a HTML emailer function built for HTML emails from this site, but I really wanted to keep this part plain text (mostly for simplicity...lol).

I've been experimenting still and came accross something peculiar (to me anyway).

When I take out all of the \n's and/or \r's, but leave spaces in the code...

Code: Select all

$display_var = "
Thank you for your order!

Below are details of your order.  Please contact us as soon as possible if there are any problems with your order.

-----------------------------------------------------------------------";
The spaces are there in the email. Does this shed any light? I have root access, so maybe I've messed some setting up.

Does this help?
Philip
User avatar
ok
Forum Contributor
Posts: 393
Joined: Wed May 31, 2006 9:20 am
Location: The Holy Land

Post by ok »

Why not using HTML only for the newline("<br>")???

I thought about something...

Instead of "\n" or/and "\r", just use the real enter, i.e:

Code: Select all

$message = "Line 1
Line 2
Line 3
End Of Message";
patch2112
Forum Commoner
Posts: 86
Joined: Sun Oct 31, 2004 9:44 am
Location: London

Yep

Post by patch2112 »

Thanks Ok,

I'm actually in process now of moving it to HTML. I've always sent (well, for the 2 years I've been doing this) multi-part, but really wanted it just to be simple, printable, and quick to develop, so I thought maybe plain text was the answer.

Just had to let go and head back over to html.

Thanks again,
Philip

PS: Couldn't use the "real enter" as I was looping to building rows. Have tables now which is better looking anyway.
Post Reply