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

那年仲夏 提交于 2021-02-10 21:54:27

问题


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            => "myemail@gmail.com",
  :password             => "password",
  :authentication       => "plain",
  :enable_starttls_auto => true
}

user_mailer.rb

class UserMailer < ActionMailer::Base
  default :from => 'email_i_want_to_send_from@gmail.com'

  def welcome_email
    mail(:to => "myemail@gmail.com", :subject => "welcome")
  end
end

Instead of receiving an email from email_i_want_to_send_from@gmail.com, a user would receive an email from myemail@gmail.com. (Yes, I am using actual email addresses and passwords when testing).

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


回答1:


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



来源:https://stackoverflow.com/questions/10355769/actionmailer-doesnt-use-default-from-or-any-from-for-that-matter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!