Jump to content

mail() not sending email


djp1988

Recommended Posts

I have a registration form, and this is the mail code that sends the users the activation link:

$body = "Thank you for registering at sitename.com. To activate your account, please click on this link:\n\n";				$body .= "http://www.sitename.com/activate.php?x=" . mysql_insert_id() . "&y=$a";				mail($_POST['email'], 'Registration Confirmation', $body, 'From: admin@sitename.com');

However, it seems some of my users are not receiving the email, I registered with a different email address and I am still waiting (1h later) for my email, and I tried with another email yesterday and also still waiting, could the mail(); function have bugs ?

Link to comment
Share on other sites

could the mail(); function have bugs ?
To check any function like this, fill the parameters with string literals so you absolutely can be sure they are formed correctly. And get a return value that you can check. So:$retval = mail('your_name@your_place.com', 'Registration Confirmation', 'Hello World!', 'From: admin@sitename.com');echo $retval;If you get the mail, it's not the function.So start looking at the parameter strings. Comment out the mail() call and just echo the strings after you've formed them. You might learn a lot.BTW, do you check if $_POST['email'] is set or empty? Could be a problem in your form.Maybe a non-printing character got stuck in there? You might try $email = trim($_POST['email']);Mostly, develop the kind of generic debugging routines I've described here. They apply just about anywhere.
Link to comment
Share on other sites

The mail function does not have a bug. The mail function is very simple. It connects to the SMTP server that you specify on the port that you specify and transmits the message for delivery to the mail transfer agent. That's all it does. The mail function will return true if it sent the message to the mail transfer agent, and false otherwise. The mail transfer agent on the server is what is responsible for picking up the new outgoing mail and actually sending it. Some free mail services also have a strict policy and will trash messages where the "from" address does not match the domain that sent the mail. Make sure the from address matches your domain, or try to test with an account other then something like yahoo or gmail.

Link to comment
Share on other sites

Got to the bottom of it now, the emails were stuck in my undesirable bin ! my mail program didn't even download it ! There were loads of emails in there I needed ! :)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...