focus
Member
- Messages
- 128
- Reaction score
- 0
- Points
- 16
I'm having trouble with the from header in the below mail script. Can anyone help?
PHP:
function is_valid_email($from_email)
{
return preg_match('#^[a-z0-9.!\#$%&\'*+-/=?^_`{|}~]+@([0-9.]+|([^\s\'"<>]+\.+[a-z]{2,6}))$#si', $from_email);
}
$headers = "From: " . $_POST["name"];
$headers .= "<" . $_POST["email"] . ">\r\n";
$headers .= "Reply-To: " . $_POST["email"] . "\r\n";
$headers .= "MIME-Version: 1.0\r\n"
. "Content-Type: text/html; charset=\"iso-8859-1\"\r\n"
. "Content-Transfer-Encoding: 7bit\r\n";
$to_email = "dada@hotmail.com";
$subject = "Watch Website Thing";
$name.=$_POST['name']."\n" ;
$from_email.=$_POST['email'] ."\n" ;
$msg.=$_POST['message']."\n" ;
$message = "
<body>
<b>Name:</b><br>
$name
<br> <br>
<b>Email:</b><br>
$from_email
<br> <br>
<b>Message:</b><br>
$msg
</body>
";
$sent = mail($to_email, $subject, $message, $headers) ;
if($sent)
{print "Your mail was sent successfully."; }
else
{print "We encountered an error sending your mail"; }
?>