ActionMailer不使用默认来源,也不使用任何“来源".对于这个问题 [英] ActionMailer doesn't use default from, or any "from" for that matter
问题描述
我正在尝试向用户发送欢迎电子邮件",但是默认的:from不起作用.它使用的是我在config/application.rb文件中指定的user_name.
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
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
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
用户不会从 email_i_want_to_send_from@gmail.com 接收电子邮件,而是从 myemail@gmail.com 接收电子邮件.(是的,我在测试时使用的是实际的电子邮件地址和密码).
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.
推荐答案
Google不允许您欺骗"发件人地址.我使用发送表格"发送我的电子邮件.
Google doesn't allow you to "spoof" a from address. I used Send Grid to send out my emails.
这篇关于ActionMailer不使用默认来源,也不使用任何“来源".对于这个问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!