user user - 2 years ago 71
PHP Question

Mailing code giving an error

I am new to php & have tried out some code in php for sending mail to user by some simple means, i am facing some issues as code giving a error..!! please help me.


$to = ' '". $_SESSION['email'] ."' ';
$subject = 'Your vault number';
$message = 'Your vault number is '". $_SESSION['vault_no'] ."' ';
$headers = 'From:' . "\r\n" .
'Reply-To:' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

Answer Source

You have a Syntax error in your string assignment:

$to      =  ' '". $_SESSION['email'] ."' ';
              ^ here                   ^ and here

You don't even need delimiters as part of your final string,

$to      =  $_SESSION['email'];

is enough, as $_SESSION['email'] already is a string.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download