Hi!
I need some help... I have this php email, It works fine (very simple and clean): when somebody sends me and email from my website, I receive the his info and he receives an autoresponder email with the mail confirmation.
Now, I'd love to send the auto responder as an html email, with logo image in the body of the email.
Could you help me? I tried everything I found on the web, but it doesnt work!
this is the code I have:
PHP Code:
<?php
function anti_spam($str) {
$str = strtolower($str);
$str = trim($str);
if ($str == 2 || $str == '2' || $str == 'two') {
return TRUE;
} else {
return FALSE;
}
}
if(isset($_POST['submit'])) {
error_reporting(E_NOTICE);
function valid_email($str)
{
return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE;
}
if($_POST['name']!='' && anti_spam($_POST['antispam'])==TRUE && $_POST['email']!='' && valid_email($_POST['email'])==TRUE && strlen($_POST['comment'])>1)
{
$to = preg_replace("([\r\n])", "", $_POST['receiver']);
$from = preg_replace("([\r\n])", "", $_POST['name']);
$subject = $_POST['subject'];
$email = $_POST['email'];
$telefono = $_POST['telefono'];
$comment = $_POST['comment'];
$time = date('j F, Y g:i a', time());
$message = "Da: $from \r\nData Invio: $time \r\nTelefono: $telefono \r\nOggetto: $subject \r\nMessaggio: $comment";
$autoTo = $_POST['email'];
$autoreply = "Salve $from,\n\rQuesto è un risponditore automatico.\n\rAbbiamo ricevuto la sua richiesta.\n\rLa contatteremo quanto prima!\n\rGrazie!\n\r"; //change this to your message
mail($autoTo, "Richiesta inoltrata con successo!", $autoreply, 'From: myemail@email.com');
$match = "/(bcc:|cc:|content\-type:)/i";
if (preg_match($match, $to) ||
preg_match($match, $from) ||
preg_match($match, $message) || preg_match($match, $subject))
{
die("Header injection detected.");
}
$headers = "Da: \"".$_POST['name']."\" <".$_POST['email'].">\n";
$headers .= "Rispondi a: ".$_POST['email']."\r\n";
if(mail($to, $subject, $message, $headers))
{
echo 1; //SUCCESS
}
else {
echo 2; //FAILURE - server failure
}
}
else {
echo 3; //FAILURE - not valid email
}
}else{
die("Direct access not allowed!");
}
?>
Thank you!!!