Jump to content

Newline characters and not sending emails out


greenhawk117

Recommended Posts

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.