tags:

views:

36

answers:

2

I need to ask a simple question to anyone. Any clue will be much appreaciated!

Could you please tell me any reason why a php mail() may not be sent?

I am pretty sure all details entered are correct from $to to $headers etc.

Please, Francesco

Code is:

<?php  
if (array_key_exists('sendEmail', $_POST)) {


    $to = '[email protected],'.$_POST['email'].''; 

    $subject = 'bla bla';  

    $headers = 'From: [email protected]>\r\n"  

        ."Reply-To: $email';  

    $message = 'Dear '.$_POST['name']."\r\n\r\n"; 

    $message .= 'Your Booking Number is '.$_POST['ID']."\r\n";  

    $message .= 'Name ' .$_POST['title']. ' ' .$_POST['firstname']. ' ' .$_POST['lastname']."\r\n";  



    mail($to,$subject,$message,$headers); 

}

?>

+1  A: 

Probably depends on the server, most of them (if you're using a hosting provider) don't allow sending mail to external domains.

kemp
A: 

Try enclosing the mail() method:

if(mail(...)) {
   echo "SUCCESS";
} else {
   echo "FAILURE";
}

The mail method will return false if transmission failed.

matiasf
Hi matias fI have tried what you said. What happens is that at the top of the page appears: "email not sent" of the else stetement I set up, before I press any button. Can this be a clue?
francesco