Forum Moderators: coopster

Message Too Old, No Replies

PHP mail() function not working!

mail() function not working!

         

pradeepa

6:20 pm on Feb 22, 2005 (gmt 0)

10+ Year Member



Hi,

I am very new to PHP. Just trying the mail() function, but it is not sending me any email.
This is my code!

<html>
<body>
<?php
$quantity = $_POST['quantity'];
$item = $_POST['item'];
$email=$quantity;
echo $email;
mail("me@example.com","Email Form Test",$item);

echo "You ordered ". $quantity . " " . $item . ".<br />";
echo "Thank you for ordering from Art Supplies!";
?>
</body>
</html>

**************************
When i tried an if statement to the mail() function, it returned True. Means it is working.
So why am i not getting email?

This drives me really crazy.
Could any one please help me with this.

Thank you.

[edited by: jatar_k at 6:44 pm (utc) on Feb. 22, 2005]
[edit reason] generalized email [/edit]

gettopreacherman

2:19 am on Feb 23, 2005 (gmt 0)

10+ Year Member



You have closed off your mail function early should be something like:

mail("me@example.com","Email Form Test",$item\n;

echo "You ordered ". $quantity . " " . $item . ".<br />";
echo "Thank you for ordering from Art Supplies!" );

?>

this way you are declaring email, subject, to, message...

jamesa

10:51 am on Feb 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is it only affecting certain ISPs? Are you able to get the email locally? You sure the code is valid and that your variables are being populated with the data you're expecting?

  • Check for spam filters.

  • Make sure you have a reverse PTR record. The IP address that you are sending from should resolve back to a domain name. If it doesn't most ISPs will block it. Simple DNS entry, if you don't control you DNS talk to your host otherwise there's a plethora of info out there.

  • Use a "trusted" From address. Commonly you'll see this which isn't enough:

    mail($to, $subject, $message, "From: joe@schmoe.tld");

    But by adding the fifth parameter below it changes a different part of the mail headers. I think this only works if the email address is a valid account on the server you're sending from:

    mail($to, $subject, $message, "From: joe@schmoe.tld",. "-fjoe@schmoe.tld");

  • Check to see if you're on any blacklists. All it takes is one report, legitimate or not, and you could end up being blocked by certain ISPs
  • coopster

    12:03 pm on Feb 23, 2005 (gmt 0)

    WebmasterWorld Administrator 10+ Year Member



    and welcome to WebmasterWorld, pradeepa!

    pradeepa

    7:59 pm on Feb 25, 2005 (gmt 0)

    10+ Year Member



    Hi all,

    Thank you so much for helping me with the email form.
    The problem was - i was using a free web host, so they
    filtered my emails as spam. Now i have a regular paid host and now i recieve my emails properly.

    Thank you all once again.
    Pradeepa.