Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


ignore nil in addresses so things do not blow up when e.g. a user had no email #451

merged 1 commit into from

3 participants


or one of the emails passed was nil


Could you please explain the usecase for this?


e.g. UserMailer.deliver( -> will blow up when 1 user has no email, there are ways around this like compact etc, but that means watching every input to cc/to/bcc all the time and always calling compact/ bcc = xxx if xxx
or risking not sending an email, so rather err on the side of ignoring -> in an error case the cc/bcc without an email address does not get an email


Ok, that sounds legitimate. I agree that they shouldn't blow up at all when there is a nil email address. Thanks for providing steps to reproduce! :)


@mikel: This patch is good to merge.


Thanks @grosser

@mikel mikel merged commit ab2c6fd into mikel:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 13, 2012
  1. @grosser

    ignore nil in addresses so things do not blow up when e.g. a user had…

    grosser authored
    … no email or one of the emails passed was nil
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 2 deletions.
  1. +2 −2 lib/mail/encodings.rb
  2. +7 −0 spec/mail/encodings_spec.rb
4 lib/mail/encodings.rb
@@ -178,10 +178,10 @@ def Encodings.unquote_and_convert_to(str, to_encoding)
def Encodings.address_encode(address, charset = 'utf-8')
if address.is_a?(Array)
# loop back through for each element
- { |a| Encodings.address_encode(a, charset) }.join(", ")
+ { |a| Encodings.address_encode(a, charset) }.join(", ")
# find any word boundary that is not ascii and encode it
- encode_non_usascii(address, charset)
+ encode_non_usascii(address, charset) if address
7 spec/mail/encodings_spec.rb
@@ -757,6 +757,13 @@
Mail::Encodings.address_encode(raw, 'utf-8').should eq encoded
+ it "should ignore single nil" do
+ Mail::Encodings.address_encode(nil, 'utf-8').should eq nil
+ end
+ it "should ignore nil in arrays" do
+ Mail::Encodings.address_encode(["", nil], 'utf-8').should eq ""
+ end
Something went wrong with that request. Please try again.