Jump to content

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 = "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.

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.