# Rails and Mails: what is the right mix?

**URL:** <https://www.ruby-forum.com/t/rails-and-mails-what-is-the-right-mix/178723>\
**Category:** Rails\
**Created:** [November 10, 2009, 5:30am UTC](https://www.ruby-forum.com/t/rails-and-mails-what-is-the-right-mix/178723 "2009-11-10T05:30:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kazim\_Z](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f08c70/32.png) [@Kazim\_Z](https://www.ruby-forum.com/u/Kazim_Z)\
**Post date:** [November 10, 2009, 5:30am UTC](https://www.ruby-forum.com/t/rails-and-mails-what-is-the-right-mix/178723/1 "2009-11-10T05:30:04Z")

</div>

I’m doing a Rails app. and at a point where I need to send out mails (  
confirmation email, weekly newsletter etc.)

I’m confused (and overwhelmed) about the choices to make for mail  
servers in  
our staging and production environments.

There is the danger of getting marked as SPAM or blacklisted. There are  
various guidelines around the internet that we can follow. Also, running  
the  
mails through SpamAssassin might help. Anything else you particularly  
found  
useful to do?

Also, we allow some customization of invite mails. What then, is a good  
way,  
to make sure that user entered text doesn’t cause us to end in spam?

The choice of mail server – third party, our own dedicated, or Google  
Mail.  
Whether this should be same in staging & production environments or  
different? Should we use a separate machine dedicated for email only?  
Can we  
initially start by using Google and later transition to some other  
choice?

The choice of domain from which to send the mails – whether should be  
same  
as our website or different?

And the fact that in Staging, we shall be testing things out and hence  
don’t  
want to send email accidentally to real people and confuse them! Should  
we  
send all our staging emails to some particular address(es) always?

What are the choices you made, or you think are good? Did it work?  
Basically  
I’m just asking for a piece of your mind and experiences you guys had.  
For anyone who had a successful experience in doing it, or even a bad  
experience which we can learn from. Thanks.

–

- Kazim Z.  
Blog: [http://tuxplayground.blogspot.com](http://tuxplayground.blogspot.com)

---

<div class="post-metadata">

**Author:** ![Kazim\_Z](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f08c70/32.png) [@Kazim\_Z](https://www.ruby-forum.com/u/Kazim_Z)\
**Post date:** [November 10, 2009, 7:28am UTC](https://www.ruby-forum.com/t/rails-and-mails-what-is-the-right-mix/178723/2 "2009-11-10T07:28:13Z")

</div>

Hi Kazim Z.

> to make sure that user entered text doesn’t cause us to end in spam?

You can watch rails screencasts 65 from Ryan for this

> The choice of mail server – third party, our own dedicated, or Google  
> Mail.  
> Whether this should be same in staging & production environments or  
> different?

What we does is for example in staging the mailserver responsible is  
[stag.ourdomain.com](http://stag.ourdomain.com)  
in QA for example  
[qa.ourdomain.com](http://qa.ourdomain.com)

> initially start by using Google and later transition to some other  
> choice?

No problem I think. In development we r using google smtp server for  
example

> And the fact that in Staging, we shall be testing things out and hence  
> don’t  
> want to send email accidentally to real people and confuse them! Should  
> we  
> send all our staging emails to some particular address(es) always?

This I am not sure .May be there some mechansim by which all mail can be  
routed to a particular address

Sijo

---

<div class="post-metadata">

**Author:** ![Kazim\_Z](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f08c70/32.png) [@Kazim\_Z](https://www.ruby-forum.com/u/Kazim_Z)\
**Post date:** [November 10, 2009, 11:12pm UTC](https://www.ruby-forum.com/t/rails-and-mails-what-is-the-right-mix/178723/3 "2009-11-10T23:12:23Z")

</div>

On Nov 9, 11:27 pm, Kazim Z. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’m doing a Rails app. and at a point where I need to send out mails (  
> confirmation email, weekly newsletter etc.)
> 
> I’m confused (and overwhelmed) about the choices to make for mail servers in  
> our staging and production environments.
> 
> There is the danger of getting marked as SPAM or blacklisted. There are  
> various guidelines around the internet that we can follow. Also, running the  
> mails through SpamAssassin might help. Anything else you particularly found  
> useful to do?

First off, make sure that whatever solution you end up with has SPF  
set up correctly, and DKIM if possible. Both of these serve to  
indicate to receiving mail servers that the mail really _is_ from you,  
and not forged by a spammer.

> Also, we allow some customization of invite mails. What then, is a good way,  
> to make sure that user entered text doesn’t cause us to end in spam?

You may want to try one of the spam checking services like Akismet -  
they’re mostly used for comments, but there’s no reason that invites  
couldn’t be screened. If you have a form where the general public can  
send emails, you WILL get linkspammers attacking it.

> The choice of mail server – third party, our own dedicated, or Google Mail.  
> Whether this should be same in staging & production environments or  
> different? Should we use a separate machine dedicated for email only? Can we  
> initially start by using Google and later transition to some other choice?

Google for Domains is OK for very small setups; note that they have a  
500 unique recipient per day limit on the free service. I’ve used  
AuthSMTP with a fair degree of success, although they can get very  
touchy about spam reports. You should be fine sending emails from the  
web server for at least a while; postfix (or equivalent) are pretty  
light on resources.

> The choice of domain from which to send the mails – whether should be same  
> as our website or different?

Once again, at first, you should definitely send emails from the same  
domain as the site. It will help users understand why they’re getting  
the mails. And trust me, you’ll need as much help as you can here.  
I’ve had users open an activation email, activate their account, get  
2/3rds of the way through profile creation and only THEN decide that  
the activation email is spam.

> And the fact that in Staging, we shall be testing things out and hence don’t  
> want to send email accidentally to real people and confuse them! Should we  
> send all our staging emails to some particular address(es) always?

Well, I just saw this: [GitHub - myronmarston/mail\_safe: Keep your ActionMailer emails from escaping into the wild during development.](http://github.com/myronmarston/mail_safe) -  
maybe it would help.

In the long run, there are “feedback loop” services for AOL, Yahoo,  
and several other of the larger mail providers. They give you direct  
access to spam reports against your domain, and are worth looking into  
if you start getting big enough to have spam problems.

One last tip: in almost any case, you should be verifying emails (via  
activation or similar) before sending any other mails. You’d think  
that users could spell their email addresses correctly, but you’d be  
wrong. I counted 50+ unique misspellings (most were repeated) of  
“[yahoo.com](http://yahoo.com)” in a 35k user application that was running without email  
validation.

Good luck!

–Matt J.
