We help IT Professionals succeed at work.

PHP email form cannot send email to a particular domain

SLPowers
SLPowers used Ask the Experts™
on
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.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2011
Top Expert 2016

Commented:
OK, please show us the code that you're using and tell us the domain name that fails, thanks.
SLPowersEngineer

Author

Commented:
<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
Most Valuable Expert 2011
Top Expert 2016

Commented:
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.
SLPowersEngineer

Author

Commented:
The form is attempting to send email to the domain hbhomedesign.com
Most Valuable Expert 2011
Top Expert 2016

Commented:
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

SLPowersEngineer

Author

Commented:
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.
Most Valuable Expert 2011
Top Expert 2016

Commented:
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
SLPowersEngineer

Author

Commented:
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
Most Valuable Expert 2011
Top Expert 2016
Commented:
The email never gets to the Antispam server...  Interesting.  Please show us the complete code for both the form and the action scripts as it exists today, having incorporated the changes suggested here.  Have you added the SPF headers?