Advice for PHP Contact Form and Web Host Spam filter

Discussion in 'PHP' started by Indi, May 2, 2007.

  1. #1
    I'm not well versed in PHP by any means. I've only just started to learn.

    However, I have a simple contact form which was working fine until the web host sent me email which states:-

    I went to their knowledge base article and it doesn't exist. :mad:

    So fine I then decided to alter the code to email the form to so there is no user 'nobody'. Basically the form is being emailed to a Gmail account.

    This is the code (excluding all the other code for validations etc):-

    require_once "Mail.php";

    $Subject = FilterCChars("Client Enquiry");

    $Body = "First Name : $FTGfirst\n"
    . "Surname : $FTGsurname\n"
    . "Telephone : $FTGtelephone\n"
    . "Mobile : $FTGmobile\n"
    . "Email : $FTGtxtEmail\n"
    . "Comments : $FTGcomments\n"
    . "";
    ini_set('SMTP', 'smtp.gmail.com');
    $To = '<accountname@gmail.com>';

    $from = "<info@mydomainname.com.au>";

    $host = "smtp.gmail.com";
    $username = "accountname";
    $password = "password";

    $headers = array ('From' => $from,
    'To' => $to,
    'Subject' => $subject);
    $smtp = Mail::factory('smtp',
    array ('host' => $host,
    'auth' => true,
    'username' => $username,
    'password' => $password));

    $mail = $smtp->send($To, $Subject, $Body, $Header);

    What happens is if someone uses the Contact Form and hits "send" it seems to send and will even take the person to the "thankyou" page. But the email is never received by me (the Form owner).

    Can anyone offer some advice please?
     
    Indi, May 2, 2007 IP
  2. brealmz

    brealmz Well-Known Member

    Messages:
    335
    Likes Received:
    24
    Best Answers:
    3
    Trophy Points:
    138
    #2
    $host = "smtp.gmail.com";

    im not sure about this but i think gmail will not allow routing message from somebodys host..

    have you try to use localhost or smtp.mydomainnamehere.com?
     
    brealmz, May 2, 2007 IP
  3. Indi

    Indi Guest

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I got it sorted. Rather than use Gmail (I suspected as brealmz suggested) I used the actual server/host's email addy (name@mydomain.com.au) and sent it from info@mydomain.com.au so that it wasn't seen to be coming from "nobody".

    That fixed it.
     
    Indi, May 3, 2007 IP