kshnurov / mandrill_dm

A basic Mandrill delivery method for Rails.
MIT License
46 stars 45 forks source link

Mail UnstructuredField undefined method `formatted' #64

Closed neohunter closed 6 years ago

neohunter commented 6 years ago

I'm a bit lost about where to report this. It's only happening if using Rails ActionMailer with an email that includes commas.

This is how to simulate the error:

MandrillDm::Message.new(Mail::Message.new(to: "Juan Monigote, Pepe <pepe@gmail.com>")).send :combine_address_fields
=> NoMethodError: undefined method `formatted' for #<Mail::UnstructuredField:0x007facda5daa50>
MandrillDm::Message.new(Mail::Message.new(to: "Juan, Pepe <pepe@gmail.com>")).send :combine_address_fields
=> ...Works

It happens if you do this:

class ApplicationMailer < ActionMailer::Base
  def generic_mail(email)
    mail(
      to: "Juan Monigote, Pepe <pepe@gmail.com>",
      subject: "test"
    )
  end

The value from to comes from an string. I'm replying to a received email, so the email in fact arrives with a ,.

kshnurov commented 6 years ago

@neohunter your to value is invalid. Look here and here