How does Action Mailer perform when sending out say 3,000 emails? I know the answer will have a lot to do with the hardware, but in general, is Action Mailer up to the task of completing an operation like this in reasonable time?
> How does Action Mailer perform when sending out say 3,000 emails? I > know the answer will have a lot to do with the hardware, but in general, > is Action Mailer up to the task of completing an operation like this in > reasonable time?I reckon that Rails won''t be the bottleneck, but sendmail or whatever you''re using to actually deliver the emails. Passing a AM action and preparing the template should be pretty darn fast. All depending on whether you''re doing some heavy model foo in each action, of course. -- David Heinemeier Hansson http://www.loudthinking.com -- Broadcasting Brain http://www.basecamphq.com -- Online project management http://www.backpackit.com -- Personal information manager http://www.rubyonrails.com -- Web-application framework
On 07/07/2005, at 6:47 PM, Ryan Jones wrote:> How does Action Mailer perform when sending out say 3,000 emails? I > know the answer will have a lot to do with the hardware, but in > general, > is Action Mailer up to the task of completing an operation like this in > reasonable time?It will be able to do it, but I wouldn''t recommend doing it in your FastCGI process... Also, if each mail is customised and you create and deliver them one at a time, be careful about forking too many sendmail processes (if you are using :sendmail as your transport)... My system sends about 50,000 emails, and takes about 300-400ms per email (its not cached or optimised...). We limited postfix to 15 processes and reniced the program that sends the emails, so as to not overload the server. one way would be to create batches of emails and send them using Net::SMTP: connect, try to send each email, then close the connection, but then you have to look out for all the Net::SMTP exceptions that you can get... bodhi
I''ve heard that qmail is a good sendmail alternative for batch email. Can anyone confirm this? I think qmail has a drop-in replacement for sendmail that accepts the same parameters. On 7/7/05, Ryan Jones <ryan-qyX6PtzcItVBDgjK7y7TUQ@public.gmane.org> wrote:> > How does Action Mailer perform when sending out say 3,000 emails? I > know the answer will have a lot to do with the hardware, but in general, > is Action Mailer up to the task of completing an operation like this in > reasonable time?_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Haven¹t used qmail but I can say that I¹ve found Postfix to be MUCH easier to use than sendmail. A Rails based mass-mailing system would be killer Mailman is based on Python but since its persistence is via Python Pickles and not a database, it is VERY SLOW for large lists. From: Carl Youngblood <carl.youngblood-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Reply-To: <carl-MJzSGySFh6ZUfOvSQQQpYw@public.gmane.org>, <rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> Date: Thu, 7 Jul 2005 10:26:42 -0700 To: <ryan-qyX6PtzcItVBDgjK7y7TUQ@public.gmane.org>, <rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> Subject: Re: [Rails] Mass mail performance I''ve heard that qmail is a good sendmail alternative for batch email. Can anyone confirm this? I think qmail has a drop-in replacement for sendmail that accepts the same parameters. On 7/7/05, Ryan Jones <ryan-qyX6PtzcItVBDgjK7y7TUQ@public.gmane.org> wrote:> How does Action Mailer perform when sending out say 3,000 emails? I > know the answer will have a lot to do with the hardware, but in general, > is Action Mailer up to the task of completing an operation like this in > reasonable time?_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Op 7-jul-2005, om 19:26 heeft Carl Youngblood het volgende geschreven:> I''ve heard that qmail is a good sendmail alternative for batch > email. Can anyone confirm this?Yes it is, and easier to configure. There are also options to limit your outgoing connections, but for the mezmlm ailing lists I run, I have it set to 100 outgoing connections which is fine for me.> I think qmail has a drop-in replacement for sendmail that accepts > the same parameters.It does, but if you can -- I haven''t checked out ActiveMailer yet -- it would even be faster if you use qmail-inject. Follow the installation instructions at http://www.lifewithqmail.org/ if you expect help from the qmail list. -- Regards, Charles.
What I currently do in PHP is pull an article from the database and then loop through all the email addresses from another database table, sending the article to each one. Using SMTP on a Windows Server. I do not use the mail() function in PHP precisely because it is not well suited to looping through thousands of addresses. I was curious if Action Mailer had the same limitations. I guess creating a console script in Ruby to send out newsletter jobs I place in a database behind the scenes would probably be the way to go. On Thu, 2005-07-07 at 12:06 +0200, David Heinemeier Hansson wrote:> > How does Action Mailer perform when sending out say 3,000 emails? I > > know the answer will have a lot to do with the hardware, but in general, > > is Action Mailer up to the task of completing an operation like this in > > reasonable time? > > I reckon that Rails won''t be the bottleneck, but sendmail or whatever > you''re using to actually deliver the emails. Passing a AM action and > preparing the template should be pretty darn fast. All depending on > whether you''re doing some heavy model foo in each action, of course.
this is my riby mass mail script - it uses ruby to run a command line
emailer called "email" postfix is my mail server.
[root@xsecore src]# email --version
email - By: Dean Jones. Email: dj-BYS8GLOzW8nsgmR90Yw4Tw@public.gmane.org
Version 2.3.0 - Date 10/12/2004-11:50:34PM_EDT
[root@xsecore src]#
here''s the script:
require ''dbi''
require ''digest/md5''
# the internal sugar user id for astuart
ASSIGNEDUSERID = "c9db9032-77ff-cd70-d238-417383cf3c01"
NEWTASKNAME = "send next months email"
FROMADDR = "andrew.stuart-7m6TYFJ5CJEAvxtiuMwx3w@public.gmane.org"
FROMNAME = "Andrew Stuart"
SMTPHOST = "emailserverhostname"
SUBJECT ="this is the message subject"
ATTACHFILENAME =
"XSEObservationsEdition7.pdf,XSEObservationsEdition8.pdf"
def sendanemail(toaddress, subject, messagetext, fromaddr, fromname,
smtphost, attachfilename)
# printf "Sending message to %s\n", toaddress
`echo "#{messagetext}" | email -r #{smtphost} -subject
"#{subject}" -attach "#{attachfilename}" -from-addr
"#{fromadd
r}" -from-name "#{fromname}" #{toaddress}`
end
dbconn =
DBI.connect(''DBI:Mysql:sugarproduction:192.168.1.101'',
''dbusername'', ''dbpassword'')
subscribers = dbconn.execute("
SELECT tasks.name,
tasks.contact_id,
tasks.parent_id,
tasks.parent_type,
contacts.first_name,
contacts.last_name,
contacts.email1
FROM tasks
INNER JOIN contacts
ON tasks.contact_id=contacts.id
WHERE tasks.name= ?
AND tasks.status <>
''Completed''
AND tasks.deleted <> 1
AND contacts.email_opt_out = ''off''
ORDER BY contacts.last_name;", "taskname to
select")
sqlnewtask = "insert into tasks (
id,
date_entered,
date_modified,
assigned_user_id,
name,
status,
parent_type,
parent_id,
contact_id,
priority,
description,
deleted
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
def msgtext(tofirstname)
return "Hello #{tofirstname},
Here''s the monthly email message - enjoy!
Cheers,
Andrew Stuart
170 Dorcas Street
South Melbourne, Victoria 3205
Phone: +61 (03) 9690 2666
Mobile: 0417 034 241
Email: andrew-7m6TYFJ5CJEAvxtiuMwx3w@public.gmane.org
Web: www.guest.com
****************************************************************
IMPORTANT
The information transmitted is for the use of the intended recipient only
and may contain confidential and/or legally privileg
ed material. Any review, re-transmission, disclosure dissemination or other
use of, or taking of any action in reliance upon,
this information by persons or entities other than the intended recipient is
prohibited and may result in severe penalties. If
you have received this e-mail in error please notify XSE, telephone +61 3
9690 2666 and delete all copies of this transmissio
n together with any attachments.
****************************************************************
"
end
dbconn.prepare(sqlnewtask) do | blah |
subscribers.each do |row|
begin
printf "***********************\n"
printf "Sending mail to %s %s %s\n", row[4], row[5],
row[6]
# warning the next line if enabled will send mail to clients
sendanemail(row[6], SUBJECT, msgtext(row[4]), FROMADDR,
FROMNAME, SMTPHOST, ATTACHFILENAME)
# generate a unique task id
taskid = Digest::MD5.hexdigest(Time.now.usec.to_s)
printf "Creating follow up task for %s %s %s\n",
row[4],
row[5], row[6]
blah.execute(
taskid,
Time.now,
Time.now,
ASSIGNEDUSERID,
NEWTASKNAME,
"Not Started",
"Accounts",
row["parent_id"],
row["contact_id"],
"High",
msgtext(row[4]),
0
)
rescue DBI::DatabaseError => e
puts "An error occurred"
puts "Error code: #{e.err}"
puts "Error message: #{e.errstr}"
#ensure
# disconnect from server
#dbh.disconnect if dbh
end
end #subscribers.each
subscribers.finish
end #sourcedb.prepare
#end of script
[root@xsecore xseo]#
http://email.cleancode.org/
As a command line utility it''s easily called by ruby and does all the
normal
email stuff.
[root@xsecore src]# email --help
Options information is as follows
email [options] recipient1,recipient2,...
-h, -help module Print this message or specify one of the below
options
-q, -quiet Suppress displayed messages (Good for cron)
-f, -from-addr Senders mail address
-n, -from-name Senders name
-b, -blank-mail Allows you to send a blank email
-e, -encrypt Encrypt the e-mail for first recipient before
sending
-s, -subject subject Subject of message
-r, -smtp-server server Specify a temporary SMTP server for sending
-p, -smtp-port port Specify the SMTP port to connect to
-a, -attach file,... Attach N binary files and base64 encode
-c, -conf-file file Path to non-default configuration file
-t, -check-config Simply parse the email.conf file for errors
-cc email,email,... Copy recipients
-bcc email,email,... Blind Copy recipients
-sign Sign the email with GPG
-html Send message in HTML format ( Make your own
HTML! )
-m, -smtp-auth type Set the SMTP AUTH type (plain or login)
-u, -smtp-user username Specify your username for SMTP AUTH
-i, -smtp-pass password Specify your password for SMTP AUTH
-g, -gpg-pass Specify your password for GPG
-high-priority Send the email with high priority
[root@xsecore src]#