Reputation: 7381
I'm racking my brain trying to figure out what the heck is going on here...
I call BidMailer.confirm(Bid.last.id).deliver
in the rails console and I'm getting the following error:
ArgumentError: An SMTP To address is required to send a message. Set the message smtp_envelope_to, to, cc, or bcc address.
My code:
environment.rb
ActionMailer::Base.smtp_settings = {
user_name: ENV['SENDGRID_USERNAME'],
password: ENV['SENDGRID_PASSWORD'],
domain: ENV['SENDGRID_DOMAIN'],
address: "smtp.sendgrid.net",
port: 587,
authentication: :plain,
enable_starttls_auto: true
}
environments/development.rb
config.action_mailer.delivery_method = :smtp
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
mailers/bid_mailer.rb
class BidMailer < ApplicationMailer
def confirm(bid_id)
@bid = present Bid.find(bid_id)
mail(
to: @bid.user.email,
subject: "Your request for #{@bid.event_name}"
)
end
end
If I print out @bid.user.email
, my email shows up properly.
Upvotes: 1
Views: 242
Reputation: 3018
You need a from
address e.g. mail(to: "[email protected]", subject: "Your request for #{@bid.event_name}", reply_to: "[email protected])
. Also try replacing @bid.user.email
with a string to debug.
Upvotes: 1