All Posts by Email, Once a Week

Media Temple logo

CSS-Tricks is brought to you in part by Media Temple, the web hosting that we both use and recommend.

Mmail not coming to gmail from contact us form?

  • # April 16, 2009 at 2:32 am

    I downloaded this form my client use free gmail account and he want to get all mail in his gmail account through contact us form. I tested this but mail not coming to gmail.

    This is the code of form php

    < ?php $EmailFrom = ""; $EmailTo = ""; $Subject = "Nice & Simple Contact Form by CSS-Tricks"; $Name = Trim(stripslashes($_POST['Name'])); $Tel = Trim(stripslashes($_POST['Tel'])); $Email = Trim(stripslashes($_POST['Email'])); $Message = Trim(stripslashes($_POST['Message'])); // validation $validationOK=true; if (!$validationOK) { print "“;

    // prepare email body text
    $Body = “”;
    $Body .= “Name: “;
    $Body .= $Name;
    $Body .= “n”;
    $Body .= “Tel: “;
    $Body .= $Tel;
    $Body .= “n”;
    $Body .= “Email: “;
    $Body .= $Email;
    $Body .= “n”;
    $Body .= “Message: “;
    $Body .= $Message;
    $Body .= “n”;

    // send email
    $success = mail($EmailTo, $Subject, $Body, “From: < $EmailFrom>“);

    // redirect to success page
    if ($success){
    print ““;
    print ““;

    I just changed this

    $EmailFrom = “”;
    $EmailTo = “”;

    to this

    $EmailFrom = “”;
    $EmailTo = “”;

    What is the problem, what is the purpose of $EmailFrom? user will fill their own email in form.

    # April 16, 2009 at 10:19 am

    The point of $Emailfrom is so that you can set a certain static email to have it LOOK like its coming from a certain person all the time. So if you set it to yourself, or to say "", it doesn’t go to spam and you can even have it separated into a particular folder everytime. However, if you set the From to the $Email parameter instead, it will grab the input the user provides and will tell you its coming from that. Its up to you there.

    # April 20, 2009 at 7:55 am

    try this

    < ?php if(isset($_POST["submit"])){ $to=""; $name=trim(addslashes($_POST["name"])); $cno=trim(addslashes($_POST["cno"])); $email=trim(addslashes($_POST["email"])); $add=trim(addslashes($_POST["add"])); $message="Name : ".$name."nn"; $message=$message."Contact No :n ".$cno."nn"; $message=$message."Email :n ".$email."nn"; $message=$message."Address :n ".$add."nn"; mail($to,"Email",$message,"From:$email"); mail("","Enquiry",$message,"From:$email"); ?>

    < ?php } ?>

      Name : Address :  
      Contact No :  
      Email :  
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed