0

Hello, I wrote a script to send out an email and it works except for the subject line. Not sure why. Anyone know? Is it the "" marks?

$to = ($_POST['e_mail']);
if (!isset($_POST['e_mail']))
  
  $subject = "Registration at MySite.com"; 
    $message = "Welcome to MySite!
				Your user account has been created. Just login at MySite.com to complete your web page, 
				or if already complete login to manage your personal account.
				Enjoy!
     
    Thank You  
     
    This is an automated response, please do not reply."; 
     
    mail($to, $subject, $message, "From: MySite\n 
  X-Mailer: PHP/" . phpversion());
2
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by phpDave
0

Use braces about if/else conditions:

$to = ($_POST['e_mail']);
if (!isset($_POST['e_mail'])){
 $subject = "Registration at MySite.com"; 
 $message = "Welcome to MySite! Your user account has been created. Just login at MySite.com to complete your web page, or if already complete login to manage your personal account. Enjoy! 
     Thank You  
     This is an automated response, please do not reply."; 
 mail($to, $subject, $message, "From: MySite\nX-Mailer: PHP/" . phpversion());
}
0

Thanks ardav. OK I should of noticed that but the email actually still worked it was just the subject line that did not work at all (No subject) and the From line reads MySite X_Mailer:PHP/5.2.1.
$message and $to to worked fine.

1
if (isset($_POST['e_mail'])){

Perhaps that? I thin k the reason it worked (kinda) before was because of this:

if (!isset($_POST['e_mail']))
 
  $subject = "Registration at MySite.com";

That was the same as doing:

if(!isset($_POST['e_mail']))$subject = "Registration at MySite.com";

WHich means subject will not be set if $_POST is not set. Everything else will be though.

Edited by diafol: n/a

Votes + Comments
Awsome
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.