dimanche 1 mars 2015

What is the easiest way to send an email from a form to a gmail account

I have a bunch of forms on a website and when the user clicks submit I would like to send the information to my gmail account. The code I am using is below but I am having issue with it. When I submit the form either it takes a long time to receive (like an hour after submitting the form) or I don't get the email at all.



// Get values from form
$customerName =$_POST['name'];
$customerPhone =$_POST['phone'];
$customerEmail =$_POST['email'];
$Year =$_POST['year'];
$Make =$_POST['make'];
$Model =$_POST['model'];
$comments =$_POST['comments'];

$to = "MyGmailAccount@gmail.com";
$subject = "Website Support Form";
$message = "Contact Details \r\n Name: " . $customerName . "\r\n Phone: " . $customerPhone . "\r\n Email: " . $customerEmail . "\r\r Information \r\n Year" . $Year. "\r\n Make: " . $Make . "\r\n Model: " . $Model . "\r\n Problem: " . $comments;

$from = "sendersEmail@whatever.com";
$headers = "From:" . $from . "\r\n";
$headers .= "Content-type: text/plain; charset=UTF-8" . "\r\n";

if(@mail($to,$subject,$message,$headers)) {
print "<script>document.location.href='http://ift.tt/1BtPWDv';</script>";
}else{
echo "Error! Please try again.";
{

Aucun commentaire:

Enregistrer un commentaire