sent auto reply email form in php

Ben Addou Abdel Ilah picture Ben Addou Abdel Ilah · Nov 5, 2014 · Viewed 16.5k times · Source

this my php code :

<?php
$to = '[email protected]';
$subject = 'New EMail From Your web site:MakeMoneyCorner.com';
$name = $_POST['name'];
$email = $_POST['email'];
$message = <<<EMAIL

from $name
his email is:$email
EMAIL;

$header = '$email';

if($_POST){
   mail($to, $subject, $message, $header, $feedback)
   $feedback = 'your information has been successfully Send it';

}

if ($mail->send()){ 
 $autoemail = new PHPMailer(); 
 $autoemail->From = "[email protected]"; 
 $autoemail->FromName = "makingmoneycorner.com"; 
 $autoemail->AddAddress($mail->From, $mail->FromName); 
 $autoemail->Subject = "This Is Your Book About Making Money"; 
 $autoemail->Body = "you can download here :";
 $autoemail->Send(); 
 }  

 ?>

** // the form work great, i can recieve emails that visitors are sending, but the reply doesn't work why ?

img of the problem :http://www.gulfup.com/?e4Nb5X

Answer

Rasclatt picture Rasclatt · Nov 5, 2014

EDIT: If your mail() is working, use that function instead of PHPMailer() because my previous code should have delivered both.

$to = '[email protected]';
$subject = 'New EMail From Your web site:MakeMoneyCorner.com';
$name = $_POST['name'];
$email = $_POST['email'];
// Your message is set up strangely, try this:
$message = "
From: ".ucwords($name)."
Sent by: $email";
// Your header needs the words "From: " in it
$header = "From: $email";

if($_POST){
    // You are saying if the mail to you succeeds, continue on.
    if(mail($to, $subject, $message, $header)) {
        // Your browser message to them
        $feedback = 'your information has been successfully Send it';
        if(filter_vars($email, FILTER_VALIDATE_EMAIL)) {
            $headerRep  = "From: makingmoneycorner.com <[email protected]>";
            $subjectRep =   "This Is Your Book About Making Money";
            $messageRep =   "you can download here :";
            mail($email, $subjectRep, $messageRep, $headerRep);
        }
    }
}