Closed Thread
Results 1 to 4 of 4
Like Tree3Likes
  • 1 Post By tonymcv1
  • 1 Post By Livewire
  • 1 Post By Livewire

Thread: PHP mailing

  1. #1
    tonymcv1 is offline x10Hosting Member tonymcv1 is an unknown quantity at this point
    Join Date
    Apr 2009
    Posts
    7

    PHP mailing

    Hi. I dont know if this is the correct way to address my problem so apologies if I'm wrong. My site has a feedback form which uses PHP to send the info to my email address. I've tried using the form but no info comes across.
    Does my free hosting suport PHP and/or do I have to enable something else to use it.
    Here is my code if it will help.

    Thanks in advance,

    Tony

    !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <META HTTP-EQUIV="refresh" content="0;URL=thankyou.html">
    <title>Email Form</title>
    </head>

    <body>
    <?php
    $name=addslashes($_POST['name']);
    $email=addslashes($_POST['email']);
    $comments=addslashes($_POST['message']);

    // you can specify which email you want your contact form to be emailed to here

    $toemail = "tonymcv1@gmal.com";
    $subject = "From EcoStyleStudio.com";

    $headers = "MIME-Version: 1.0\n"
    ."From: \"".$name."\" <".$email.">\n"
    ."Content-type: text/html; charset=iso-8859-1\n";

    $body = "Name: ".$name."<br>\n"
    ."Email: ".$email."<br>\n"
    ."Comments:<br>\n"
    .$comments;

    if (!ereg("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$", $email))
    {
    echo "That is not a valid email address. Please return to the"
    ." previous page and try again.";
    exit;
    }

    mail($toemail, $subject, $body, $headers);
    echo "Thanks for submitting your comments";
    ?>
    </body>
    </html>
    dinomirt96 likes this.

  2. #2
    Livewire's Avatar
    Livewire is offline Abuse Compliance Officer Livewire is a glorious beacon of lightLivewire is a glorious beacon of light
    Join Date
    Jun 2005
    Location
    Behind a keyboard.
    Posts
    8,998

    Re: PHP mailing

    The from address must be one actually on your x10hosting account, or it will be blocked because of it forging headers. In your case, setting the from address to a gmail address is your problem - gmail isn't an x10hosted service, and to put it lightly they -really- hate it when people forge headers to make it seem like it came from them when it didn't. There's two options - use Google Apps and SMTP to send the emails through the google apps service themselves, or change the from address to one on your hosting account.

    There may be other problems with it sending, but that's the first one I'm seeing - our outbound email system won't even let this one get outside the x10hosting network because it's forging a header.
    verlmirt17 likes this.


    TOS breakers will be suspended regardless of race, creed, national origin, hair color, or favorite food. Thanks for your understanding!

  3. #3
    tonymcv1 is offline x10Hosting Member tonymcv1 is an unknown quantity at this point
    Join Date
    Apr 2009
    Posts
    7

    Re: PHP mailing

    Hi. Thanks for reply.
    I've tried changing my code to the following but I'm still having no joy with it going through:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <META HTTP-EQUIV="refresh" content="0;URL=thankyou.html">
    <title>Email Form</title>
    </head>


    <body>
    <?php
    $name=addslashes($_POST['name']);
    $email=addslashes($_POST['email']);
    $comments=addslashes($_POST['message']);


    // you can specify which email you want your contact form to be emailed to here


    $toemail = "tonymcv@tonymcv.x10.mx";
    $subject = "Tonys Site";


    $headers = "MIME-Version: 1.0\n"
    ."From: \"".$name."\" <".$email.">\n"
    ."Content-type: text/html; charset=iso-8859-1\n";


    $body = "Name: ".$name."<br>\n"
    ."Email: ".$email."<br>\n"
    ."Comments:<br>\n"
    .$comments;


    if (!ereg("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$", $email))
    {
    echo "That is not a valid email address. Please return to the"
    ." previous page and try again.";
    exit;
    }


    mail($toemail, $subject, $body, $headers);
    echo "Thanks for submitting your comments";
    ?>
    </body>
    </html>

  4. #4
    Livewire's Avatar
    Livewire is offline Abuse Compliance Officer Livewire is a glorious beacon of lightLivewire is a glorious beacon of light
    Join Date
    Jun 2005
    Location
    Behind a keyboard.
    Posts
    8,998

    Re: PHP mailing

    What are you passing as the from email here: $headers = "MIME-Version: 1.0\n"
    ."From: \"".$name."\" <".$email.">\n"

    That's the from email address I meant to refer to; if that from is -not- an x10hosting based email the mailing system will deny it. If this is for a contact form, you might do better having the From and To address both be one from your hosting account, then have the body say "This is feedback sent from <actual email address here>" - this won't anger the mailing system but it'll still tell you the email address entered.
    karimirt47 likes this.


    TOS breakers will be suspended regardless of race, creed, national origin, hair color, or favorite food. Thanks for your understanding!

Closed Thread

Similar Threads

  1. mailing list
    By clay13 in forum Free Hosting
    Replies: 1
    Last Post: 04-02-2010, 08:04 PM
  2. SMF : PHP Mailing
    By smartflight in forum Free Hosting
    Replies: 11
    Last Post: 03-01-2010, 09:51 PM
  3. Mailing lists are gone
    By maclan in forum Free Hosting
    Replies: 0
    Last Post: 11-12-2008, 11:14 AM
  4. Mailing list
    By Fsmvda in forum Free Hosting
    Replies: 0
    Last Post: 10-16-2008, 04:36 PM
  5. php mailing?
    By frutsel in forum Scripts & 3rd Party Apps
    Replies: 2
    Last Post: 03-09-2008, 01:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers