Forum Moderators: mack
I have come across this problem: the mail() function from php doesn't seem to do its job.
I'm using a form which points to a php page which collects the information entered in the form and sends it to me by email using the mail() function and also sends to the user a confirmation message at the email address entered.
The first part is completed with success, I get the information from the form, but the user doesn't receive the confirmation message. Instead I get a error message "Mail delivery failed: returning message to sender" with a copy of the message and "unrouteable mail domain" - for whatever email address entered.
I think the problem is that mail() doesn't read properly the $email variable, because if I use a predefined constant such as $email="email@addresss.com" the messeage reaches at its destination.
Here's the source:
<?php
$email = $_REQUEST['email'];
...
mail ("$email", "Email subject", "Email body", "From: Me <my_email@my_address.com>");
?>
What is the problem? And the solution.
Any input would be highly appreciated.
Thank you.
Searching the programming forums on the net I've seen this is quite a common problem among the webmasters (in some cases).
I thinking:what if I change my hosting server - would it make a difference? Or what if I use just for that a php page hosted on a different server - in a different website. And then just use <?php include('http://othersite.com/mailpage.php');?>
where mailpage.php contains the mail() function.
I'll try it and let you know of its result.
I have managed to avoid somehow this issue, having noticed that the only domain name that mail() can sen email to, is my own.
Therefore, I sent an email to another email address of mine, which was set as an auto-responder, such sending the confirmation message.
But this way doesn't allow me to send personalized email messages, which is baaad.