Hello,
I have a problem with the emails sent with mail().
They all arrive to the users without linebreaks. I've tried \n but that doesn't work. What is the problem. Server setup?
Scott
| SitePoint Sponsor |
Hello,
I have a problem with the emails sent with mail().
They all arrive to the users without linebreaks. I've tried \n but that doesn't work. What is the problem. Server setup?
Scott



Not sure if this would be a problem, or if it would apply when sending emails, but is your message in double quotes or single quotes?
eg:
$message = "blah \n";
or
$message = 'blah \n';
Oh no! the coots are eating my nodes!
The text is pulled out of a db with a function but as far as I can tell the $message variable is surrounded in double quotes.
Scott
Have you noticed that this forum also has no linebreaks in the emails sent from it?
Only the excerpt has linebreaks. Here is what I recieved:
See what I mean?Code:Hello scamo, timnz has just replied to a thread you have subscribed to entitled - email has no line breaks! - in the PHP and MySQL forum of SitePoint Community Forums. Excerpt: Not sure if this would be a problem, or if it would apply when sending emails, but is your message in double quotes or single quotes? eg: $message = "blah \n"; or $message = 'blah \n'; This thread is located at: http://sitepointforums.com/showthrea...4&goto=newpost There may be other replies also, but you will not receive any more notifications until you visit the board again. Yours, SitePoint Community Forums team ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Unsubscription information: To unsubscribe from this thread, please visit this page: http://sitepointforums.com/member2.p...threadid=31694 To unsubscribe from ALL threads, please visit this page: http://sitepointforums.com/member2.p...type=allthread
Scott
Last edited by scamo; Aug 20, 2001 at 03:31.





Trya \r\n where you want the line breaks.
Please don't PM me with questions.
Use the forums, that is what they are here for.





Um, the emails from this forum have always worked perfectly for me...maybe something's wrong with your email client. They've always had line breaks for me.![]()





You must do:
$text = str_replace("\n", "\r\n", $text);



Do you really have to do that? Because the emails I have sent myself through one of my email scripts, worked perfectly when I had like:
$str = "Hello\nThis is on a newline";
Oh no! the coots are eating my nodes!
I think we have come closer to an answer. My colleague found out something. You can determine the content-type in the header of your email when using the mail() function. Something like this:Of course for non-html emails the line '$headers = "Content-Type: text/html; blah blah', should have text/plain written in it.Code:$message = "The following email includes a formatted ASCII table\n"; $message .= "Day \t\tMonth \t\tYear\n"; $message .= "3rd \t\tAug \t\t1970\n"; $message .= "17rd\t\tAug \t\t1973\n"; $headers = "Content-Type: text/html; charset=iso-8859-1\n"; mail("$address","Teste mail() Funktion",$message,$headers);
We'll see if that'll do the trick!
Thanx everyone for your input.
Scott
Bookmarks