Forum: Ruby on Rails questions @mailer best practice

Posted by Tom Tom (tingle)
on 2012-06-27 13:21
(Received via mailing list)
hi

i'm currently sending emails via smtp, but i wanna change a few things:

1) external smtp > local mta
>> it seems there is a lag when using external smtp, so i was wondering
whats the best way to separate the whole email sending from the
application, like putting it into a queue?

2) how can i call a deliver() method only once but still have a
personalized email? eg a personalized newsletter:
Newsletter.sendoutmonhtlynewsletter(User.all).deliver
>> how can i reference a username & useremail and still send it once out eg
via bcc multiemail (in respect of bcc limits))?
( i assume this would b a bit more efficent, or at least out more load 
on
the emailserver then on the application)

3) whats the best way to send out emails so that they can be replied to?
like github and other service?


if sone could share their experience, pro & cons that would help a lot

thx

tom
Posted by Walter Davis (walterdavis)
on 2012-06-27 16:43
(Received via mailing list)
On Jun 27, 2012, at 7:20 AM, tom wrote:

> hi
>
> i'm currently sending emails via smtp, but i wanna change a few things:
>
> 1) external smtp > local mta
> >> it seems there is a lag when using external smtp, so i was wondering whats 
the best way to separate the whole email sending from the application, like 
putting it into a queue?

There's an excellent Railscast about this, covers this precise pain 
point, and shows you (I think) two different ways to solve it. Have a 
search there.

>
> 2) how can i call a deliver() method only once but still have a personalized 
email? eg a personalized newsletter:
> Newsletter.sendoutmonhtlynewsletter(User.all).deliver
> >> how can i reference a username & useremail and still send it once out eg via 
bcc multiemail (in respect of bcc limits))?
> ( i assume this would b a bit more efficent, or at least out more load on the 
emailserver then on the application)

If you're sending to a whole list of people, take a serious look at 
SendGrid and other (paid, but SOOOOO worth it) hosted sending services. 
This is an unbelievably twisted barrel of eels that you are looking in 
to, I can tell you from bitter experience. As far as your code goes, I 
don't think you ever want to send out a bunch of Bcc messages at a time, 
not unless you want to virtually guarantee non-delivery owing to SPAM 
traps and the like.

>
> 3) whats the best way to send out emails so that they can be replied to? like 
github and other service?

Uh, that's just a matter of setting the :from address to a real address. 
Unless that was a typo, and you meant /can't/ be replied to. Again, it's 
just a matter of setting the :from address to a real address, although 
you would then configure an auto-responder at the mail server level to 
instantly reply 'don't do that again'. And if you mean reply to an 
e-mail but have it be accepted by the Rails app as input, I was just 
looking at this problem yesterday. Again, SendGrid has a well-oiled 
solution in this space, but you can roll your own, and again, Ryan Bates 
has a screencast about it. (He HAS done everything, at least once, on 
his Railscast site.)

Walter
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.