Welcome Guest | Login

The best way to deliver mass emailings on HostingRails.com

is.....???  :-)

No, I'm not trying to become a part-time spammer... I have an opt-in newsletter, with a few hundred subscribers. I'm building a RoR app to send out my emails.

Basically, I wanted to know if there's a problem with just iterating through my database and calling an ActionMailer method for each one like so:

for user in users
 NewsletterMailer.deliver_newsletter(user)
end
The reason I ask is because I saw this "scary" note on the RoR wiki: "When you want to send a mail to a large number of recipients, you shouldn’t do it purely with ActionMailer as it opens an SMTP connection for each mail sent." There was also a link to this kludgy script. Do I need to do that?

Thanks!

Luke

2007-01-18 07:24 PM

You should check out ar_mailer.  We have it installed on all our servers.  cPanel places a limit of 250 emails/hr/domain on outgoing email to prevent spam - and ar_mailer will help queue up emails so you can get 200 out every hour.  Also, just use Sendmail to send out emails - if you use SMTP then indeed it will open and close a connection every time it would be crazy slow.

2007-01-19 06:00 AM

Excellent... I will have to investigate ar_mailer further, but from a quick cursory glance it looks great. I will make sure to stay under the limit.

Thank you!

2007-01-19 04:06 PM

I successfully set up ar_mailer and used it to send emails to 400+ website subscribers. It saves all your emails into a database table and sends them out when you run ar_sendmail.

You can configure the sending options so emails are delivered in small batches and set the delay in between. I tried a batch size of 200 and a delay of 3600 seconds (1 hour) but I think this overwhelmed the mail server as not all my emails went out. I have since been recommended by support to try sending batches of 10 so a 180 second delay will send 200 in an hour. I'll report on the success of this configuration after I send my next email newsletter.

However since the server was upgraded this week to rails 1.2.2 I have been unable to run ar_sendmail and received the following errors:

[~/myapp]# ar_sendmail --batch-size 10 --delay 180
/usr/local/bin/ar_sendmail:17:Warning: require_gem is obsolete.  Use gem instead.
./config/boot.rb:28:Warning: require_gem is obsolete.  Use gem instead.
/usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:246:in `activate': can't activate activesupport (= 1.3.1), already activated activesupport-1.4.1] (Gem::Exception)
       from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:264:in `activate'
       from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:263:in `each'
       from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:263:in `activate'
       from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:76:in `active_gem_with_options'
       from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:61:in `require_gem'
       from ./config/boot.rb:28
       from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
       from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
        ... 12 levels...
       from /usr/local/lib/ruby/gems/1.8/gems/ar_mailer-1.1.0/lib/action_mailer/ar_sendmail.rb:279:in `run'
       from /usr/local/lib/ruby/gems/1.8/gems/ar_mailer-1.1.0/bin/ar_sendmail:5
       from /usr/local/bin/ar_sendmail:18:in `load'
       from /usr/local/bin/ar_sendmail:18
[~/myapp]#
If anyone else uses ar_mailer and has any ideas how to get around this problem please let me know.

Thanks :)

2007-02-08 12:32 PM

www.alttab.co.uk
Just a quick update on the problem I was having above with ar_sendmail. It was fixed by updating a line in my environment.rb from
RAILS_GEM_VERSION = '1.1.6'
to
RAILS_GEM_VERSION = '1.2.2'

2007-02-09 08:31 AM

www.alttab.co.uk
I've just been having a play with ar_sendmail - like it and want to use it, so now have a couple of questions....

As I want something going in the background sending mails out when they are there, is it recommended to run ar_mailer from cron?? From what's been said in the thread already it could be set up with a batch size of 10 and run every 2 mins (although this seems a tad 'wasteful' as most of the time the cron job's not going to be doing anything as I expect my mailings to be quite sporadic).

Also, if a cron job is the way to go, what is the path to ar_sendmail that should be used in the crontab to run the command?

Cheers

Rupert

2007-03-11 03:24 PM

Hi Rupert,

You can also run it from cron with -o, or as a daemon with -d.

See ar_sendmail -h for full details.

The path for ar_sendmail is '/usr/local/bin/ar_sendmail'

Also please check the link for more details
http://www.gemjack.com/gems/ar_mailer-1.1.0/classes/ActionMailer/ARMailer.html

2007-03-12 06:55 AM

Thanks for the info Rahjaz

I had a go at running it as a daemon, but nothing happens at all :(  It's not a great problem as I can always run a regular cron job to clear any emails in the queue.  But just in case I'm doing anything wrong I'd thought I'd check back here first!

I ssh'd into my account and entered:

ar_sendmail  --batch-size 10 --delay 180 -d

from within my rails directory.  The prompt comes back as I expected, but no mails get sent fromthe queue.  If I run it without the -d then it  sends mails.  But of course this is no good as I need to be able to kick it off and log out leaving it running on the server. The documentation doesn't offer any help and I get no error when trying to run it as a daemon so I'm a bit stumped!

If you can offer any advice I'd be greatful - no worries if not as the cron root is beckoning!

Cheers

Rupert

2007-03-16 01:52 PM


Hello Guest! In order to post you must be an active client with us, please log in or sign up today!