ArgumentError: An SMTP To address is required to send a message. Set the message smtp_envelope_to, to , cc, or bcc address

bulleric picture bulleric · Aug 24, 2013 · Viewed 26.3k times · Source

I got an rails 4 application with following mailer configuration:

config.action_mailer.delivery_method = :smtp
  config.action_mailer.default_url_options = { host: 'myhost.com' }
  config.action_mailer.perform_deliveries = true

  config.action_mailer.smtp_settings = {
    :enable_starttls_auto => true,
    :address            => 'smtp.myhost.com',
    :port               => 587,
    :domain             => 'myhost.com',
    :authentication     => :login,
    :enable_starttls_auto => false,
    :tls                  => false,
    :openssl_verify_mode  => 'none',
    :ssl => false,
    :user_name          => "myusername",
    :password           => "mypassword"
  }

Every time i try to send an mail with an testing mailer setup:

class TestMailer < ActionMailer::Base

  default :from => "[email protected]"

  def welcome_email
    mail(:to => "[email protected]", :subject => "Test mail", :body => "Test mail body")
  end
end

TestMailer.welcome_email.deliver

I got this exception:

ArgumentError: An SMTP To address is required to send a message. Set the message smtp_envelope_to, to , cc, or bcc address.

Is it possible that i forget something to set.? And i can't find an configuration option for "smtp_envelope_to"

Answer

Miotsu picture Miotsu · Aug 27, 2013

The error message is not about the SMTP envelope, but about the sender:

An SMTP To address is required to send a message

the rest is just a generic message. Something in your [email protected] is not working. Do you use a real, working address? If not, try with one.