Brian Weinreich
Brian Weinreich

Reputation: 7712

ActionMailer doesn't use default from, or any "from" for that matter

I'm trying to send out "Welcome Emails" to my users, however, the default :from is not working. It is using the user_name I specify in the config/application.rb file.

This is the code I currently have.

config/application.rb

ActionMailer::Base.smtp_settings = {
  :address              => "smtp.gmail.com",
  :port                 => "587",
  :domain               => "domain.com",
  :user_name            => "[email protected]",
  :password             => "password",
  :authentication       => "plain",
  :enable_starttls_auto => true
}

user_mailer.rb

class UserMailer < ActionMailer::Base
  default :from => '[email protected]'

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

Instead of receiving an email from [email protected], a user would receive an email from [email protected]. (Yes, I am using actual email addresses and passwords when testing).

Anyone have any ideas as to why this is happening? Thanks.

Upvotes: 1

Views: 768

Answers (1)

Brian Weinreich
Brian Weinreich

Reputation: 7712

Google doesn't allow you to "spoof" a from address. I used Send Grid to send out my emails.

Upvotes: 7

Related Questions