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 = "[email protected]"; $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 <[email protected]>"; 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. 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 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 = "[email protected]"; $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 <[email protected]>"; 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. 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' 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
Archived
This topic is now archived and is closed to further replies.