user user - 7 months ago 14
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.

php

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

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

Answer

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.