[Rails] Multiple emails from one SMTP connection?
Gerret Apelt
gerret.apelt at gmail.com
Wed Jan 4 16:57:13 GMT 2006
Ryan,
if you're not customizing the email on a per-recipient basis,
definitely go for sending you email in a single SMTP session. I
believe the ActionMailer API doesn't let you do that as-is.
ActionMailer uses the TMail library internally though, so you might be
able to intercept the TMail instance generated by ActionMailer, and
then send it to multiple recipients, taking away the SMTP portion of
the work from ActionMailer and doing it yourself.
In pseudo-brief, somewhat like this
Net::SMTP.start(server, port) do |sender|
recipients.each do |recipient|
tmail.to = recipient
sender.sendmail tmail.encoded, tmail.from, [recipient]
end
end
Exactly where to intercept the Tmail object created by ActionMailer,
you'd have to dig to find out.
cheers
Gerret
On 1/4/06, Ryan Wood <ryan.wood at gmail.com> wrote:
> Hi all. I'm running a nightly job that is creating a CSV file and
> sending to member via SMTP. I got the following error after about 20
> emails or so: Net::SMTPServerBusy Too many connections from IP...
>
> Is there a way (using ActionMailer) to open a connection and send
> multiple emails. Or could I make sure the connection is closed before
> opening another? The only other option is to send some type of wait
> signal if I catch that error. Any other ideas?
>
>
> Thanks for the help!
>
> --Ryan
> _______________________________________________
> Rails mailing list
> Rails at lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
More information about the Rails
mailing list