Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a website where people can recommend contents to their friends using their email. The issue is that emails are being flagged as spam whereas if I do the same from my development machine things are working out fine. I have enabled SPF and it is perfect.

When sending through website, the email appears as this in Gmail Inbox: From to

When I send it from my development machine it appears as : From via to mailed by and this is exactly how I envisioned it.

From what little I could figure out by looking at the source of emails in Gmail is that when sending from my development machine Gmail correctly recognizes my domain as for which SPF is enabled and hence it treats it as genuine email. Whereas Gmail recognizes my domain as when sent through the website. Can someone tell me why it does so?

Any help would be really appreciated.

share|improve this question

migrated from Jul 1 '11 at 14:18

This question came from our site for professional and enthusiast programmers.

Well, I'd guess that Google gives you a higher spam score for saying "this is from someone", but SPF for doesn't match that. – Piskvor Jul 1 '11 at 14:07

2 Answers 2

Google's antispam takes into account many more variables than just SPF records. You need to check with them to understand why your mail is being blocked. Start by reading their guidelines for bulk senders:

Then if you are still unsure contact their postmaster.

Make sure your domain has feedback loops setup with all the major destination mail providers as well, so you'll be notified of issues.

share|improve this answer
Thanks mfarver. I will do that. – S Asif Raza Jul 1 '11 at 15:45
up vote 2 down vote accepted

I figured out where the problem was. So in case someone has the same problem, he can do this:

In php's mail function I was not specifying envelope-sender address and therefore php was defaulting it to something like this mywebsite

I specified it like this as an additional parameter : '-f'

Now php mail function will look something like this: mail($toaddress, $subject, $mailcontent, $fromaddress, '-f');

This solved my problem.

share|improve this answer
If this solved your problem, you should accept your answer – Michael Lowman Jul 8 '11 at 15:14
@michael lowman I am new to this site. Will you tell me how to close this question. – S Asif Raza Jul 8 '11 at 15:29
you should click the check mark next to this answer, and it will turn green. and welcome to serverfault :) – Michael Lowman Jul 8 '11 at 15:36
@michael lowman Thanks. – S Asif Raza Jul 8 '11 at 15:36
Thanks Asif, that really helped me out - I was getting emails arriving in gmail with 'via' and the -f parameter was exactly what I needed. – Dave Hilditch Apr 9 '13 at 16:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.