greenhawk117 Posted October 5, 2007 Share Posted October 5, 2007 I am using a simple mail script to send out emails for a webpage that I designed. The script works fine until I insert the newline character (\n). Anytime I insert it, the webpage runs fine but no email is sent out. As soon as I take the newline character out of the mail script, emails are sent out just fine. I am really confused by this. Any suggestions? Here is my code: $takenby = $_POST['taken_by']; $poster = $_POST['posted_by']; $shiftbegin = $_POST['time_begin']; $shiftend = $_POST['time_end']; $shiftdate = $_POST['shift_date']; $to = "men4@buffalo.edu"; $subject = "Lockwood Shift Request - $takenby requesting $poster's shift"; $message .= "'$takenby' is requesting to take a shift posted by '$poster'\n"; $message .= "The shift is on $shiftdate from $shiftbegin to $shiftend"; $headers = "From: Lockwood Shifts Server <men4@buffalo.edu>"; mail($to, $subject, $message, $headers); The above code will not work with the \n command in there but if I take it out, the email is sent out just fine. Quote Link to comment https://forums.phpfreaks.com/topic/72019-newline-characters-and-not-sending-emails-out/ Share on other sites More sharing options...
sdi126 Posted October 5, 2007 Share Posted October 5, 2007 Is this a windows box? If so try \r\n Quote Link to comment https://forums.phpfreaks.com/topic/72019-newline-characters-and-not-sending-emails-out/#findComment-362993 Share on other sites More sharing options...
pkSML Posted October 5, 2007 Share Posted October 5, 2007 Here is my code: $takenby = $_POST['taken_by']; $poster = $_POST['posted_by']; $shiftbegin = $_POST['time_begin']; $shiftend = $_POST['time_end']; $shiftdate = $_POST['shift_date']; $to = "men4@buffalo.edu"; $subject = "Lockwood Shift Request - $takenby requesting $poster's shift"; $message .= "'$takenby' is requesting to take a shift posted by '$poster'\n"; $message .= "The shift is on $shiftdate from $shiftbegin to $shiftend"; $headers = "From: Lockwood Shifts Server <men4@buffalo.edu>"; mail($to, $subject, $message, $headers); #1: line 1 of $message should start with $message =, not $message .= #2: line 1 of $message - both variables in the string should be enclosed in braces, not single quotes --> {}, not ' ' Try fixing those and let us know if things work out. Quote Link to comment https://forums.phpfreaks.com/topic/72019-newline-characters-and-not-sending-emails-out/#findComment-363017 Share on other sites More sharing options...
marcus Posted October 5, 2007 Share Posted October 5, 2007 Um, @ pkSML 1. The message variable is fine. 2. It's still fine. He's calling the variable inside double quotes, but surrounding them by single quotes. 'name' is requesting... 'poster' Quote Link to comment https://forums.phpfreaks.com/topic/72019-newline-characters-and-not-sending-emails-out/#findComment-363020 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.