We have a Rails app that uses a third party SMTP server to deliver email. Everything was working correctly except emails going to gmail and hotmail addresses were disappearing. It was bizarre. There was no bounce back and email were being delivered to other email hosts.
So we checked the mail logs (much later than we should have when the problem arose, but that’s another story) and saw this entry when delivering to gmail:
Connected to 188.8.131.52 but sender was rejected.
Remote host said: 555 5.5.2 Syntax error.
What the funk? Ok so we checked the headers of the emails and noticed something out of the ordinary:
Return-Path: <“name <noreply”@ourdomain.com>
X-Spam-Checker-Version: SpamAssassin 3.1.9 (2007-02-13) on emailserver.com
X-Spam-Status: No, score=-2.5 required=7.0 tests=BAYES_00,FORGED_RCVD_HELO
Received: (qmail 6005 invoked from network); 6 Dec 2010 23:10:17 -0500
Received: from appserver.com (HELO ourdomain.com) (184.108.40.206)
by emailserver.com with SMTP; 6 Dec 2010 23:10:16 -0500
Right off the bat we can see something fishy going on. Return-Path: <“name <noreply”@ourdomain.com> doesn’t look right at all. It turns out that our email server was incorrectly formatting the return path which was then being rejected by gmail and hotmail.
What to do? There are settings that we could change to specify the Return-Path on the SMTP server but that seemed like it would require a lot of configuration. So being the lazy developers we are we decided against that. We tried specifying the Return-Path in the Rails ActionMailer model but the mail server was overwriting it. Since this was a live site and emails needed to be delivered to one of, if not the largest (sorry, i didn’t feel like looking up the stats) email providers we decided to just remove the name from the from field so the emails came from firstname.lastname@example.org.
It’s kind of a hacky solution but it worked for us and there aren’t any problems so far. Leave a comment if you have come up with a better solution!
The problem is a perform_delivery_smtp method from ActionMailer::Base used in rails 2.3.4 and 2.3.5. You can always try to monkey-patch-it like that:
Hello admin do you need unlimited content for your page ?
What if you could copy content from other sites, make it pass copyscape test and publish on your website – i know the right tool for you, just search in google:
Loimqua’s article tool