Link to home
Start Free TrialLog in
Avatar of SLPowers
SLPowersFlag for United States of America

asked on

PHP email form cannot send email to a particular domain

We have a form that sends email to user@emaildomain.com The email is never sent and does not reach the domain at all. When changing the form to send to an alternate address and alternate domain it succeeds.

The PHP code does not know how to resolve or see the MX record for one domain.
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

OK, please show us the code that you're using and tell us the domain name that fails, thanks.
Avatar of SLPowers

ASKER

<html>
<body>

<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
   {
   //send email
   $email = $_REQUEST['email'] ;
   $subject = $_REQUEST['subject'] ;
   $message = $_REQUEST['message'] ;//cari@hbhomedesign.com
   mail("cari@hbhomedesign.com", "$subject",
   $message, "From:" . $email);
   echo "Thank you for using our mail form";
   }
else
//if "email" is not filled out, display the form
   {
   echo "<form method='post' action='mailform.php'>
   Email: <input name='email' type='text' /><br />
   Subject: <input name='subject' type='text' /><br />
   Message:<br />
   <textarea name='message' rows='15' cols='40'>
   </textarea><br />
   <input type='submit' />
   </form>";
   }
?>

</body>
</html>h
OK, now what domain is giving you trouble?  BTW, a "reply to" address might be helpful in case the domain is polite enough to bounce the message.
The form is attempting to send email to the domain hbhomedesign.com
Couple of ideas... You might need to terminate the "additional headers" field as shown in line 16 of this code snippet.  It worked to send the email message to myself.  You might also have an email server that knows it's living at hbhomedesign.com so it outsmarts itself by rejecting emails that come from that domain, assuming they are forgeries.

You might consider adding spf records, too.
http://www.mxtoolbox.com/SuperTool.aspx?action=spf%3ahbhomedesign.com

Nice looking site! ~Ray
<?php // RAY_temp_slpowers.php
error_reporting(E_ALL);


// THE RECIPIENT - CHANGE TO TEST AS NEEDED
$to = 'Ray.Paseur@Gmail.com';
$to = 'cari@hbhomedesign.com';

// IF THE FORM HAS BEEN POSTED
if (isset($_POST['email']))
{
    mail
    ( $to
    , $_POST['subject']
    , $_POST['message']
    , "From: {$_POST['email']}\r\n"
    )
    ;
    echo "Thank you for using our mail form";
}
else
{
    echo "<form method='post'>
    Email: <input name='email' type='text' /><br />
    Subject: <input name='subject' type='text' /><br />
    Message:<br />
    <textarea name='message' rows='15' cols='40'>
    </textarea><br />
    <input type='submit' />
    </form>"
    ;
}

Open in new window

Thank you. I'll forward you suggesstion to the web host. Then email server is not connetected with hbhomedesign.com so that shouldn't be the issue.

Thanks again.
email server is not connected with hbhomedesign.com -- "not connected" in a variety of ways!

I have seen this before.  The server administrator thinks that she should be the only one who can send emails from X@hbhomedesign.com.  And so when an email arrives from a foreign IP address that has a FROM email address at hbhomedesign.com she bounces or discards the email.  Some spam filters implement awkward logic like this.  The fallacy is that "If I am hbhomedesign.com, nobody else could be hbhomedesign.com, so I can reject any emails that say they came from hbhomedesign.com."  And the problem is that she does not control the FROM address of emails from others, who are filling in a form on a web site.  It's another of the many ineffectual anti-spam tricks that frustrated novices have used to try to outsmart the spammers.  They end up outsmarting themselves and their clients.

Am I 100% sure that is the issue?  No, but it smells like it.  Sadly, the email system was invented by nerd scientists who never considered the fact that forgeries could pollute the system.  All they wanted to do was exchange scientific information.  They never envisioned any economic value for email.  And they were right, up until about 2003.  And what has been done to secure the system in the intervening eight years?  Nothing.  This has spawned a variety of anti-spam businesses and an even larger and bizarre variety of home-made anti-spam techniques.  The vast majority of them do not work or produce false positives.  The system will get fixed when there is a criminal legal penalty for sending email from a server that does not have valid SPF records.  Until then, we can expect many opportunities to enlarge our manhood or make millions for doing nothing, etc.

Tell them to convert to name-brand Google Mail.  I get about fifty to seventy emails a day, and three or four spam messages a year that get past the Google spam filters into my in-box.  However I NEVER miss a good message.  There is a value in using professional services, and my experience with Google Mail has proven that value to me.

Best regards, ~Ray
The email never gets to the Antispam server so I don't think this is the problem. I have no record anywhere of the email ever hitting the anti spam server. The email flows when it's sent to a different address that is not hbhomedeisgn.com (my email address-dan@slpowers.com) but that address is also filtered on this server.
By the way, we use Secnap hosted Antispam and I also get hundreds of pieces of spam per week and I NEVER see them. I get maybe 1 email per week delivered to my quarantine and I also never miss a legitimate email.
I appreciate your help.

Dan
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial