Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding several To addresses not possible? #23

Closed
ba opened this issue Jan 15, 2010 · 4 comments
Closed

Adding several To addresses not possible? #23

ba opened this issue Jan 15, 2010 · 4 comments

Comments

@ba
Copy link

ba commented Jan 15, 2010

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 'first-address@domain.tld'
to 'second-address@domain.tld'
...
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'] = 'first-address@domain.tld, second-address@domain.tld'
....
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

@mikel
Copy link
Owner

mikel commented Jan 16, 2010

You can just do:

mail = Mail.new do
  to 'first-address@domain.tld, second-address@domain.tld'
end

Each time you assign to='value' it will overwrite the previous value.

Mikel

@ba
Copy link
Author

ba commented Jan 16, 2010

Thanks Mikel, missing something completely obvious it is :)

@mikel
Copy link
Owner

mikel commented Jan 16, 2010

no problem :)

@kakubei
Copy link

kakubei commented Jan 13, 2014

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', 'recipiento2@domain.com'

    to %w[recipient1@domain.com recipient2@domain.com]

    to ['recipient1@domain.com', 'recipient2@domain.com']

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.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants