Question

Situation: Our client (owner of domain.com) has set the A record for www.domain.com to the IP address of one of our servers where we run the website behind domain.com. We only provide hosting for this domain, they have their own email servers.

This means that domain.com has another IP than the mail server for domain.com.

Problem: Sending mails from PHP to foo@bar.com works BUT sending mails to *@domain.com does not work.

Question: Does this has something to do with SPF records? How do I solve this?

thx

Bundy

Was it helpful?

Solution

This happened to me on a shared host as well as is probably because there is a local delivery mechanism in place on the web server, i.e. when your web server sees an email for @domain.com it assumes it will be the one to handle, and does not pass in on to the actual mail server.

Go into your web server's panel (Cpanel or whatever) and check your email settings for this domain. Make sure "local delivery" or something similar is disabled for domain.com

OTHER TIPS

Does your main domain.com (without www.) have an CNAME record? This will automatically refer the mx record of the domain to the cname record.

The characteristic payload information of an MX record is the fully qualified domain name of a mail host and a preference value. The host name must map directly to one or more address record (A, or AAAA) in the DNS, and must not point to any CNAME records.

http://en.wikipedia.org/wiki/MX_record#cite_note-0

The best way to send emails is using a smtp method:

http://sourceforge.net/projects/phpmailer/files/phpmailer%20for%20php4/0.90/

Example file:

<?php
require("class.phpmailer.php");

$mail = new PHPMailer();

$mail->IsSMTP();                                      // set mailer to use SMTP
$mail->Host = "mail.example.net";  // specify main and backup server
$mail->SMTPAuth = true;     // turn on SMTP authentication
$mail->Username = "user@example.net";  // SMTP username
$mail->Password = "password"; // SMTP password

$mail->From = "example@example.net";
$mail->FromName = "Mailer";
$mail->AddAddress("destiny@example.net");


//$mail->AddReplyTo("info@example.com", "Information");

$mail->WordWrap = 50;                                 // set word wrap to 50 characters
//$mail->AddAttachment("/var/tmp/file.tar.gz");         // add attachments
//$mail->AddAttachment("/tmp/image.jpg", "new.jpg");    // optional name
$mail->IsHTML(true);                                  // set email format to HTML

$mail->Subject = "Here is the subject";
$mail->Body    = "This is the HTML message body <b>in bold!</b>";
$mail->AltBody = "This is the body in plain text for non-HTML mail clients";

if(!$mail->Send())
{
    echo "Message could not be sent. <p>";
    echo "Mailer Error: " . $mail->ErrorInfo;
    exit;
}

echo "Message has been sent";
?>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top