I have a form which works fine for a customer to fill out and I receive an email with the information. I know want it to where the form sends the information TO the customer FROM me. When I switch the sender and receiver, though, i get and error:
(FYI [email protected] is the email I use to test, that the customer would use)
Warning: mail() [function.mail]: SMTP server response: 550 [email protected] No such user here in E:\inetpub\vhosts\atlantasbestguttercleaners.com\httpdocs\superemailtest2.php on line 51
Warning: Cannot modify header information - headers already sent by (output started at E:\inetpub\vhosts\atlantasbestguttercleaners.com\httpdocs\superemailtest2.php:51) in E:\inetpub\vhosts\atlantasbestguttercleaners.com\httpdocs\superemailtest2.php on line 54
HERE IS THE CODE:
[php]<?php
$your_email =‘quot[email protected]’;// <<=== update to your email address
session_start();
$errors = ‘’;
$Name = ‘’;
$Email = ‘’;
$phone = ‘’;
$phone2 = ‘’;
$user_message = ‘’;
if(isset($_POST[‘submit’]))
{
$Name = $_POST['Name'];
$first = $_POST['first'];
$Email = $_POST['Email'];
///------------Do Validations-------------
if(empty($Name)||empty($Email))
{
$errors .= "\n Name and Email are required fields. ";
}
if(IsInjected($Email))
{
$errors .= “\n Bad email value!”;
}
if(empty($_SESSION[‘6_letters_code’] ) ||
strcasecmp($_SESSION[‘6_letters_code’], $_POST[‘6_letters_code’]) != 0)
{
//Note: the captcha code is compared case insensitively.
//if you want case sensitive match, update the check above to
// strcmp()
$errors .= “\n The captcha code does not match!”;
}
if(empty($errors))
{
//send the email
//send the email
$to = $Email;
$subject="this is a test";
$from = $your_email;
$ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
$message = "test";
$headers = “From: $from \r\n”;
$headers .= “Reply-To: $Email \r\n”;
mail("$to","$subject","$message","From: ME <$from>\n" . "MIME-Version: 1.0\n" . "Content-type: text/html; charset=iso-8859-1");
header('Location: thank-you.html');
}
}
// Function to validate against any email injection attempts
function IsInjected($str)
{
$injections = array(’(\n+)’,
‘(\r+)’,
‘(\t+)’,
‘(%0A+)’,
‘(%0D+)’,
‘(%08+)’,
‘(%09+)’
);
$inject = join(’|’, $injections);
$inject = “/$inject/i”;
if(preg_match($inject,$str))
{
return true;
}
else
{
return false;
}
}
?>
[/php]