I’ve spent the last two days trying to add an autoreply email function to my web page. It seems that there are tons of tips out there, but every time I try, it fails. I’m not sure what I’m doing run, and I’m feeling pretty stupid about the whole thing. I hope someone can look at this and tell me why I keep getting:
Warning: mail() [function.mail]: SMTP server response: 550 [email protected] No such user here in E:\inetpub\vhosts\yourdomain.com\httpdocs\testy.php on line 56
Warning: Cannot modify header information - headers already sent by (output started at E:\inetpub\vhosts\yourdomain.com\httpdocs\testy.php:56) in E:\inetpub\vhosts\yourdomain.com\httpdocs\testy.php on line 58
here is the code:
[php]<?php
$your_email =‘[email protected]’;// <<=== update to your email address
$autosubject = “Thank you for requesting your Free Quote”;
session_start();
$errors = ‘’;
$Name = ‘’;
$Email = ‘’;
$user_message = ‘’;
if(isset($_POST[‘submit’]))
{
$Name = $_POST['Name'];
$Email = $_POST['Email'];
$user_message = $_POST['message'];
///------------Do Validations-------------
if(empty($Name)||empty($Email))
{
$errors .= "\n Name and Email are required fields. ";
}
// validate an email address
if( !preg_match("/^[_a-z0-9-]+(.[_a-z0-9-]+)@[a-z0-9-]+(.[a-z0-9-]+)(.[a-z]{2,3})$/i", $Email) ) {
$errors .= “\n You have entered and invalid email address”;
}
if(IsInjected($Email))
{
$errors .= “\n Bad email value!”;
}
if(empty($errors))
{
//send the email
//send the email
$to = $your_email;
$subject=“there is an email from a customer”;
$from = $Email;
$ip = isset($_SERVER[‘REMOTE_ADDR’]) ? $_SERVER[‘REMOTE_ADDR’] : ‘’;
$message = "This is the message from the customer";
$message2 = “This is the message to the customer”;
$headers = “From: $from \r\n”;
$headers .= “Reply-To: $Email \r\n”;
$headers2 = “From: [email protected]”;
$headers2 .= “Reply-To: $your-email \r\n”;
mail($your_email,"$subject","$message",“From: $Name <$Email>\n” . “MIME-Version: 1.0\n” . “Content-type: text/html; charset=iso-8859-1”);
mail($from, $autosubject, $message2, “From: Me <$your_email>\n” . “MIME-Version: 1.0\n” . “Content-type: text/html; charset=iso-8859-1”);
header(‘Location: http://www.mydomain.com/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;
}
}
?>
".nl2br($errors)."
"; } ?> .blueBoxText{ line-height:120%; font-size:12px; font-family:Arial, Verdana, Helvetica, sans-serif; }Name: |
Email: |