So I'm working on a web application, and today I was trying to send invites out to some users. Turns out that they were going into the gmail spam filter.
I made sure that my RDNS (Reverse DNS) was set up correctly, and then I checked the email headers to ensure that gmail didn't suspect my ISP's IP address as a spammer IP.
A friend suggested that it might have something to do with the content of my emails, and not the body.
So I started playing around and, sure enough, that was it. After several emails I realized that it had to do with the link I was sending in the email. At first I thought that it might have to do with the length of the link (and an MD5-encoded token in the params).
After several tests I figured out exactly what trips it: If I send email from a foo.com server (hostname = foo.com, DNS and RDNS consistent with foo.com) with a signup link for foo.com, then that sends the mail to spam. If, on the other hand, I send email from a bar.com server with a link to foo.com, then the email makes it through the spam filter.
That seems so non-intuitive to me. It seems more shady for an email from bar.com to have a link to foo.com in it.
Anyways, I've got a temporary work-around (I think?), but I still don't know the 'right' way do this.