PavelTyk/sendgrid-rails — Issue #1: ruby mail gem refuses to deliver mail with no/empty recipient
Author: ggerhard
Created: 2012-01-12 21:14:52+00:00
State: open

When I tried to send an email to multiple recipients, I got the following error (on rails console):

ruby-1.9.2-p180 :002 > mail.deliver
ArgumentError: At least one recipient (To, Cc or Bcc) is required to send a message
from /home/dev/.rvm/gems/ruby-1.9.2-p180/gems/mail-2.3.0/lib/mail/network/delivery_methods/smtp.rb:102:in `deliver!'

I saw that mail.header['to'] is set to nil in the MailInterceptor class, it seems that the deliver method does not support that.

I think it's the check in line 101 in this file:
https://github.com/mikel/mail/blob/master/lib/mail/network/delivery_methods/smtp.rb

Maybe the sendgrid API would accept a dummy recipient?