Sending email: my ' come out as \'
Posted: Sat Feb 02, 2008 5:27 am
This is probably a very simple problem but for all the mails I send through mail(), why do my ' always come out as \' ?
Here's the code I use which I made from scratch. Maybe you can tell me what's wrong with it:
Here's the code I use which I made from scratch. Maybe you can tell me what's wrong with it:
Code: Select all
<?php
$myemail = "email@gmail.com";
$myname = "John Doe";
$sender = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$header =
"Recipient: $myname <$myemail>\n" .
"Subject: $subject\n" .
"From: $sender <$email>\n" .
"X-Mailer: PHP 4.x";
//send the mail + error messages
if(mail($myemail, $subject, $message, $header))
{
$sender = rawurlencode($sender); //comes out as \\\\' so I guess I have to take this out
Header("Location: http://domain.com/emailSent.php");
}
else
{
Header("Location: http://domain.com/emailNotSent.php");
}
?>