0

Possible Duplicate:
PHP mail stopped working

I'm using PHP mail() function to send a Contact Us form. This works for all the emails that I've tried but the ones with the customer's company suffix:[something]@3gdirectpay.com. The function returns true, but he doesn't get anything, even after checking the spam.

The code:

<?php

$email="You have recieved a new message from a customer: \r\n \r\n";
if (isset($_POST)) {
    foreach ($_POST as $key=>$value) {
        if (isset($value) && $value!='' && $key[0]!='x' && $key!='mf_mail' && $key!=='mf_text') {
            $email.=$_POST['x' . $key] . $value . "<br>";
        }
        else if ($key=='mf_text') {
            $text = "Message: " . $value;
        }
}
$headers = 'MIME-Version: 1.0' . "\r\n"; 
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";   
$email.= $text;
$to = "info@3gdirectpay.com, eran@3gdirectpay.com";
$from = $_POST['mf_mail'];
$subject = "New message from a customer";
mail($to,$subject,$email,$headers);



    }

header("Location:http://www.3gdirectpay.com/?m=sent");

?>

The customer said that they are hosting their mail services with Gmail. I am quite positive it has something to do with the suffix, but what can cause such a peculiar behavior?

Community
  • 1
  • 1
Matanya
  • 6,233
  • 9
  • 47
  • 80
  • If you `echo($to)` what value do you get? – slashingweapon Nov 23 '12 at 19:14
  • `mail()` returns `TRUE` when it successfully passes the message to your outbound SMTP server. It does not and _cannot_ know what happens to the message after that. The recipient domain might flat out refuse to accept mail from your server, rather than send to spam. – Michael Berkowski Nov 23 '12 at 19:17
  • Thanks @Michael. But what can be the reason for that? What in my server definitions can make it unreliable or perceived as hazardous to the recipient domain? – Matanya Nov 23 '12 at 19:20
  • that's like asking "my package was sent to mail but it was never received. what's the problem?". we can't really know, you'll need to start debugging - check MX records, check mail server logs... – eis Nov 23 '12 at 19:22
  • 1
    @Matanya There are many many reasons. If it is a shared host or service like EC2, sometimes those IPs get blacklisted by Spamhaus et al, some receiving servers don't like certain headers, some will validate that the `From` header's domain matches the domain of the server sending it (which yours may not since you take `From` from $_POST). It is impossible to say. – Michael Berkowski Nov 23 '12 at 19:25

0 Answers0