Bcc not working with ActionMailer
jefmathiot opened this issue · 5 comments
Steps to reproduce:
In a Rails app, set the delivery method to mailjet_api
and create a mailer class and the template notify.txt.erb
:
class WhateverMailer < ApplicationMailer
def notify(opts)
mail(opts.merge(subject: 'Hello'))
end
end
Deliver an email with a to
recipient:
WhateverMailer.notify(to: 'test@example.com').deliver_now
The email is delivered.
Now use bcc
instead of to
:
WhateverMailer.notify(bcc: 'test@example.com').deliver_now
The following exception is raised:
NoMethodError (undefined method `display_name' for "test@example.com":String)
Having a similar issue. Any updates from Mailjet on this?
Hi , I would be interested by a reply on this also !
@jefmathiot Could you please provide an error stacktrace, rails and mailjet gem versions? Thanks
Closiing due to inactivity. Please re-open if the issue appears again.
This is still happening.
I am getting the same error when using a BCC with ActionMailer.
I think mailjet.rb is assuming that the keys in the mail
object are of type Mail::Address
, whereas I think they are raw from ActionMailer
of type string or array of strings (from ActionMailer docs: " can be a string of addresses, or an array of addresses").
Further, looking through the mailjet.rb class, the code below sticks out for other reasons:
if (mail[:cc])
if (mail[:cc].is_a? String)
if mail[:cc].display_name.first
ccs =[{:Email=>mail[:cc].address.first, :Name=>mail[:cc].display_name.first}]
If mail[:cc]
is of type String, it surely won't respond to .display_name
.
Are we sure this gem ok to use with ActionMailer??