Вопрос

I have the following setup:

Server 1 (client-server):

  • Running at 111.111.111.111
  • Hosting myawesomedomain.com with email server.
  • Includes TXT DNS: "V=SPF1 A MX INCLUDE:MYAWESOMEDOMAIN.COM ip4: 222.222.222.222/32 ?ALL"

Server 2 (one of my machines):

  • Hostname: warning.othercorp.net
  • Running at 222.222.222.222.

I want to use the server 2, via PHP mail()function to send email email warning to registered users in a back office.

I tried to send mail with a simple PHP script like the following but it gets marked as SPAM in Oulook.com and GMAIL says it was sent via warning.othercorp.net

$to = "someone@outloook.com";
$subject = 'Warning!';
$message = 'hello! You\'ve been warned!';
$headers = 'From: warning@myawesomedomain.com' . "\r\n" .
    'Reply-To: info@myawesomedomain.com' . "\r\n";

$res = mail($to, $subject, $message, $headers);
var_dump($res);

I'm not an expert in email sending, but what can I do to avoid emails marked as spam? Wasn't the SPF entry with the IP of the server 2 enough? Why?


Edit:

I was doing some tests, and after viewing the source of a test email sent to an @gmail address, I got this:

Received-SPF: neutral (google.com: 222.222.222.222 is neither permitted nor denied by best guess record for the domain of warning@myawesomedomain.com) client-ip=222.222.222.222;

I guess Outlook is flagging the email as spam because it has the same problem of GMAIL, what should I do?

Thank you!

Это было полезно?

Решение

To send mail from myawesomedomain.com, I think the TXT record for myawesomedomain.com should be:

"v=spf1 a mx ip4:222.222.222.222 ?all"

Provided that:

  • the A record for myawesomedomain.com is your 111.111.111.111 address
  • your MX records are pointing to machines that actually send mail for the domain (as opposed to just receiving).

I suspect your /32 CIDR notation is causing the issue with the second server.

Другие советы

Incorrectly placed or double spaces in an SPF record can invalidate the record.

The record you've shared is:

V=SPF1 A MX INCLUDE:MYAWESOMEDOMAIN.COM ip4: 222.222.222.222/32 ?ALL

There should be no space between ip4: and 222.222.222.222

That might help solve the remaining issue for you.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top