Adding several To addresses not possible?
Hi,
I've been trying add to several to addresses to an outgoing e-mail.
Reading Mail::Message:to (and to=) documentation I found nothing about several recipients.
I tried to add several recipents by:
mail = Mail.new do
to '[email protected]'
to '[email protected]'
...
end
puts mail
Which just sets the to field to the second address. Then I tested adding them as an array into to but then I got an error about gsub on an array.
I ended up doing mail = Mail.new do self['To'] = '[email protected], [email protected]' .... end puts mail
Which set To to both addresses and the mail was delivered successfully to all recipients.
Is this the intended way of doing this or am I missing something obious? :)
/ba
You can just do:
mail = Mail.new do
to '[email protected], [email protected]'
end
Each time you assign to='value' it will overwrite the previous value.
Mikel
Thanks Mikel, missing something completely obvious it is :)
no problem :)
This doesn't work for me. No matter how I add the multiple recipients, ti only gets delivered to the first one. I've tried:
mail = Mail.new do
to 'recipient1@domaincom', '[email protected]'
to %w[[email protected] [email protected]]
to ['[email protected]', '[email protected]']
I only ever get an email to the first recipiento only. No errors.
If I do it from an IRB, I can see the mail.to only holds the first recipient. The rest get put into the subject for some strange reason.