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!