I'm using PHP _EOL when building the message body of my email but the line feeds are not getting through and the entire message body ends up one long line in the resultant email. This happens regardless of Multi-part or html only messages. Sending as text only it works fine, but of course I want to send Multi-part messages.... Any ideas?
A:
I've never even used PHP_EOL before, but I wonder if it is set to the type of your server, not of the recipient. I don't see how a constant could be correct for all recipients, that doesn't make sense.
Usually '\n' is all that is needed... in some cases you may need '\r\n' depending on the protocol involved. What are you using to send the email? What are you using to view the email?
DGM
2009-03-31 03:18:15
PHP _EOL is a constant that adjusts for each server type. But since I'm using a Windows server, sending to a Windows client, through the gmail mail server, I would expect the html-email to properly display the line feeds.
2009-03-31 03:24:42
SMTP requires CRLF... see http://www.ietf.org/rfc/rfc2821.txt section 2.3.7
DGM
2009-03-31 15:28:33
+1
A:
Uhm. If there are no line breaks in your HTML email, it's probably because neither a \n nor a \r\n is a newline in HTML; a <br /> tag is.
chaos
2009-03-31 03:36:58
I thought email accepted \r\n even in HTML only mode. I'm guessing I'm incorrect and my html emails must be 100% html to format as expected?
2009-03-31 04:18:28
Yeah. I mean, it *accepts* the \r\n, as far as that goes, it just renders it as normal for HTML: as generic whitespace.
chaos
2009-03-31 04:46:49
Yeah, that's the problem I'm having, so I need to have two different mail messages formatted for text only and HTML if I want to send mail out Multi-part
2009-03-31 05:35:58
Well... if you're not doing HTML formatting in it, what's the point of sending out an HTML part? If it's just mimicking plaintext, send plaintext. If for some reason you really need an HTML rendition of a plaintext message, though, it doesn't seem so bad to put a <br> before each newline.
chaos
2009-03-31 06:50:44
I guess I need the HTML more than the plain text. It will have coded links to sections of the site and plain text just doesn't work very well like that.
2009-04-01 01:22:32
Ah, I see. Yeah, in that case you'll need to at least put <br>s for your newlines, more preferably do proper formatting with <p>s and whatnot.
chaos
2009-04-01 01:38:34