free hosting service - Need PHP Mail help

Discussion in 'Scripts, 3rd Party Apps, and Programming' started by au001com, May 11, 2014.

  1. au001com

    au001com New Member

    Likes Received:
    Trophy Points:
    Hi, I am fairly new to php. any way i have added a feedback form and when ever i try to send a test feedback to my email i don't actually receive any thing.
    I test this using xampp and it works fine.

    i was informed it's to do with using smtp or something.

    My php code is as listed. Please note email address has been removed.

    $name = $_POST['name'];
    $priority = $_POST['priority'];
    $message = $_POST['message'];
    $formcontent=" From: $name \n Priority: $priority \n Message: $message";
    $recipient = "";
    $subject = "Feedback";
    $mailheader = "From: \r\n";
    mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
    echo " Thank you for your feedback" . " -" . "<a href='contact.html' style='text-decoration:none;color:green;'>Return</a>";

    any help would be good.

  2. caftpx10

    caftpx10 Well-Known Member

    Likes Received:
    Trophy Points:
    I see that there is a mistake in your code.

    $formcontent=" From: $name \n Priority: $priority \n

    The code mark in red is incorrect.
    The one below should do for that part:

    $formcontent = " From: " . $name . "\n Priority: " . $priority . "\n";
    You may want to apply the way I did it into your code.

    This code is also vulnerable to email injection, refer to this to test and fix this vulnerability:

    I would in fact suggest looking into the links below the article to try to fill in as much holes as possible.

    Using 'or die()' is a bad way of error handling, why?:
    What to use instead?:

    Also, X10 could've disabled the mail function since there is already a email service thingy on CPanel which you should use.
    But please be aware that sending too much emails in a short time can get your account suspended so I would really do something about spamming.
    Last edited: Jun 6, 2014
    • Like Like x 1
  3. Skizzerz

    Skizzerz Contributors Staff Member Contributors

    Likes Received:
    Trophy Points:
    mail() is enabled and can be used. Note that you must use \r\n when separating email headers, simple \n is not sufficient (you are doing this, but just making it clear). Those two PHP snippets posted above perform the same task (@caftpx10: look up string interpolation in PHP, you can actually embed $variables in double-quoted strings and it works just fine). You are also missing the "To:" header, although that shouldn't impact the successful sending of email.

    I checked our email system and it successfully sent all of your feedback emails, so the issue is somewhere on your end -- check your spam folder to see if it landed up there, and if not it is possible that your email provider is blocking emails from x10.
    • Like Like x 1

Share This Page