# Net/SMTP Question

**URL:** <https://www.ruby-forum.com/t/net-smtp-question/111662>\
**Category:** Ruby\
**Created:** [August 9, 2007, 4:16pm UTC](https://www.ruby-forum.com/t/net-smtp-question/111662 "2007-08-09T16:16:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lmcilwain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ac91a4/32.png) [@lmcilwain](https://www.ruby-forum.com/u/lmcilwain)\
**Post date:** [August 9, 2007, 4:16pm UTC](https://www.ruby-forum.com/t/net-smtp-question/111662/1 "2007-08-09T16:16:11Z")

</div>

Hello all,

I am trying to get Net/SMTP to send emails to 2 separate arrays of  
emails within the same block of code. I use this script to send out  
notifications for testing and I want to be able to cc the developers  
on the fly if I need to. Right now there is an array of email for the  
people that need to test and then a separate array for the developers  
that I want to CC if I need to. The reason I am doing it this way is  
for mainly for the placement of email address’. I don’t want to have  
the developers in the To: line of the email but the CC: line. Right  
now if I try to use this it will send the email to the first array of  
emails but seems to stop there and not move on to the second array  
emails. Can anyone help me understand what it is that I am doing  
wrong?

Here is the snippet of code I’m working with:

require ‘net/smtp’  
emailsto = []  
emailcc = []

email\_to = gets.scan(/\S+/).join(‘,’)  
emailto \<\< email\_to

emails = gets.scan(/\S+/).join(‘,’)  
emailcc \<\< emails

email = 'This is an email to be sent"

Net::SMTP.start(‘[hostname.domain.com](http://hostname.domain.com)’, 25) do |smtp|  
smtp.send\_message(email,‘removed\_email\_address@domain.invalid’,  
‘removed\_email\_address@domain.invalid’,‘removed\_email\_address@domain.invalid’,‘removed\_email\_address@domain.invalid’,‘removed\_email\_address@domain.invalid’,  
emailsto[index], emailcc[index])  
end
