# ActionMailer and \*nix Fork Question

**URL:** <https://www.ruby-forum.com/t/actionmailer-and-nix-fork-question/126763>\
**Category:** Rails\
**Created:** [January 22, 2008, 12:30am UTC](https://www.ruby-forum.com/t/actionmailer-and-nix-fork-question/126763 "2008-01-22T00:30:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phoenix\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/5e9695/32.png) [@Phoenix\_R](https://www.ruby-forum.com/u/Phoenix_R)\
**Post date:** [January 22, 2008, 12:30am UTC](https://www.ruby-forum.com/t/actionmailer-and-nix-fork-question/126763/1 "2008-01-22T00:30:37Z")

</div>

Hello all -

I’m working on a project for a newsletter and customer contact  
management system that will be responsible for sending a large number  
of (non-spam) e-mails to customers. In the past, I put together a  
quick “hack” of a PHP script to do something similar for a one-time  
case, and ran into a problem that I’d like to ensure doesn’t happen  
with my implementation of this in Rails.

Long story short, at the time, my PHP script looked something like  
this in pseudo-code  
foreach $person {  
send\_email  
}

This had an unfortunate side effect caused by me not thinking - it  
didn’t wait for mail() to finish, it kept spawning new mail processes  
in the operating system. As this was taking place on a VPS, it filled  
up RAM -very- quickly and caused the entire VPS instance to crash.

Needless to say, I’d like to avoid a similar situation with Rails!

So my question is, let’s say I have one message that I’m sending to  
multiple people. In pseudo-code:  
@message = “Hello World!”  
for u in @users  
some\_actionmailer\_module.deliver(arguments)  
end

Now let’s also assume that I have an SMTP server set, and the delivery  
method is SMTP via the same host (defined by the actual domain name,  
not just “localhost” of course).

Will Rails automatically wait for each message to be sent without any  
further intervention from me, the programmer, or will it just keep  
processing and flooding SMTP as fast as the loop can execute?

If the latter, how can I instruct Rails to wait for the connection to  
be established, information transferred, and closed properly before  
continuing the loop?

Thank you very much for your time and your help =)  
~ Phoenix
