mail icon indicating copy to clipboard operation
mail copied to clipboard

Adding several To addresses not possible?

Open ba opened this issue 16 years ago • 4 comments

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

ba avatar Jan 15 '10 11:01 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

mikel avatar Jan 16 '10 01:01 mikel

Thanks Mikel, missing something completely obvious it is :)

ba avatar Jan 16 '10 09:01 ba

no problem :)

mikel avatar Jan 16 '10 12:01 mikel

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.

kakubei avatar Jan 13 '14 13:01 kakubei