I am trying to send a reset password email with Devise.
Error:
: An SMTP To address is required to send a message. Set the message smtp_envelope_to, to, cc, or bcc address.
from /app/vendor/bundle/ruby/2.1.0/gems/mail-2.5.4/lib/mail/check_delivery_params.rb:9:in `check_delivery_params'
from /app/vendor/bundle/ruby/2.1.0/gems/mail-2.5.4/lib/mail/network/delivery_methods/smtp.rb:98:in `deliver!'
from /app/vendor/bundle/ruby/2.1.0/gems/mail-2.5.4/lib/mail/message.rb:2129:in `do_delivery'
from /app/vendor/bundle/ruby/2.1.0/gems/mail-2.5.4/lib/mail/message.rb:234:in `deliver'
from (irb):27
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.0.2/lib/rails/commands/console.rb:90:in `start'
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.0.2/lib/rails/commands/console.rb:9:in `start'
from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.0.2/lib/rails/commands.rb:62:in `<top (required)>'
I tried constructing a mail object manually:
mail = Mail.new do
from 'name@mydomain.com'
to 'name@mydomain.com'
subject 'This is a test email'
body File.read('body.txt')
end
and running mail.smtp_envelope_to
returns []
. When I ran mail.To = 'name@mydomain.com',
mail.smtp_envelope_to returns
["name@mydomain.com"].
Why am I getting this error?
EDIT: SMTP_SETTINGS
if Rails.env.staging? || Rails.env.production?
SMTP_SETTINGS = {
address: ENV['SMTP_ADDRESS'], # example: 'smtp.sendgrid.net'
authentication: :plain,
domain: ENV['BASE_URL'], # example: 'this-app.com'
password: ENV['SENDGRID_PASSWORD'],
port: '587',
user_name: ENV['SENDGRID_USERNAME']
}
end
EDIT: the missing quote was a bad re-type. See the SMTP_SETTINGS for my Rails code. The first block of code is me trying to reproduce the mail error from the console.
Turns out a Gem from Suspenders I thought I removed, recepient-interceptor, was left in.
Removing that fixed the issue.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.