Jump to content

Textarea Line Breaks Lost When I Use Contents In Mailto


chibineku
 Share

Recommended Posts

I have a contact form, very simple, just an e-mail address field, subject field and a textarea. The e-mail message (from the textarea) comes out as one long string, even when I hit the return when typing on the form. Do I need to insert a newline character every X characters myself in PHP before sending the mail?Here is a link so you can see it for yourself:http://sinaesthesia.co.uk/contact_the_webmaster.htmlEdit: Okay, the jitteriness was caused by checking the field inputs onkeyup, now i do it onblur and it looks nicer. So, the textarea thing is the only problem and that's more a PHP issue I think....

Edited by chibineku
Link to comment
Share on other sites

No, I hadn't been, but I added that, and to no avail. This is the PHP code:

$headers  = "MIME-Version: 1.0 \r\n";$headers .= "Content-type: text/html; charset=iso-8859-1 \r\n";$headers .= "To: Jonathon <chibineku@aol.com> \r\n";$headers .= "From: $tr_email \r\n";$to = "chibineku@aol.com";$subject = "AromaClear E-Mail from: $tr_email";  $msg = "From: $tr_email \r\n";  $msg .="Subject: $tr_subject \r\n";  $msg .= "Message: $tr_body \r\n";// Mail itmail($to, $subject, $msg, $headers);

And this is a sample output:From: chibineku@aol.com Subject: test Message: I am testing this to see what the formatting is like for long sentences, and what happens when I hit return. Like now, for example, I left a clear space. This time, no space, but a definate carriage return. Let\'s see No formatting, and no line breaks. Also, the quote that is escaped is odd - I'm not using any sort of encoding, it must be automatic.

Link to comment
Share on other sites

If it was being sent as HTML, that's when the line breaks wouldn't appear. Remember that in HTML, line breaks are only displayed if you use <br> elements.You can pass the string through the nl2br() function to see if anything changes.

Link to comment
Share on other sites

Great, that did it, thanks!

Link to comment
Share on other sites

For some reason, my mailto script only works if I give it a valid 'from' address - i.e. the mail doesn't reach me if I give it something bogus as the from address. That's pretty weird, since the 'to' address is hard coded and doesn't depend on the from address in any way...Hm, think it didn't like the header formatJonathon <chibineku@aol.com>Works okay without just the straight email address.

Edited by chibineku
Link to comment
Share on other sites

Does that include checking if the domain exists? Spam e-mails with valid domains seem to pass.

Link to comment
Share on other sites

Generally they just check the domains from the Received: and From: headers, and if they don't match they mark it as spam. Depends on how strict your spam filter is though.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...