title: An SMTP to address is required to send a message
body: <p>I am trying to send a reset password email with Devise.</p>
  
  <p>Error: </p>
  
  <pre><code>: 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 `&lt;top (required)&gt;'
  </code></pre>
  
  <p>I tried constructing a mail object manually:</p>
  
  <pre><code>mail = Mail.new do
    from    'name@mydomain.com'
    to      'name@mydomain.com'
    subject 'This is a test email'
    body    File.read('body.txt')
  end
  </code></pre>
  
  <p>and running <code>mail.smtp_envelope_to</code> returns <code>[]</code>. When I ran <code>mail.To = 'name@mydomain.com',</code>mail.smtp_envelope_to<code>returns</code>["name@mydomain.com"].</p>
  
  <p>Why am I getting this error?</p>
  
  <p>EDIT: SMTP_SETTINGS</p>
  
  <pre><code>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
  </code></pre>
  
  <p>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.</p>