我如何设置邮件主机,以便我可以使用一台用于生产,一台用于开发 Rails
我的邮件程序中有以下内容:
#activate board first using a different email?
def welcome_manager(participant)
@participant = participant
@user = participant.user
@board = participant.board
@url = birthday_url(@participant.token, :host => "birthday-greeting.net")
mail(:to => @user.email, :subject => "Confirmation: #{@board.bp_name.possessive} Happy Birthday Board Created" )
end
它在线使用主机。 但是,当我在开发中时,我想使用 localhost:3000,如下所示:
#activate board first using a different email?
def welcome_manager(participant)
@participant = participant
@user = participant.user
@board = participant.board
@url = birthday_url(@participant.token, :host => "localhost:3000")
mail(:to => @user.email, :subject => "Confirmation: #{@board.bp_name.possessive} Happy Birthday Board Created" )
end
我该怎么做?
I have the following in my mailer:
#activate board first using a different email?
def welcome_manager(participant)
@participant = participant
@user = participant.user
@board = participant.board
@url = birthday_url(@participant.token, :host => "birthday-greeting.net")
mail(:to => @user.email, :subject => "Confirmation: #{@board.bp_name.possessive} Happy Birthday Board Created" )
end
Which uses the host online.
However when I am in development I want to use localhost:3000 as follows:
#activate board first using a different email?
def welcome_manager(participant)
@participant = participant
@user = participant.user
@board = participant.board
@url = birthday_url(@participant.token, :host => "localhost:3000")
mail(:to => @user.email, :subject => "Confirmation: #{@board.bp_name.possessive} Happy Birthday Board Created" )
end
How can I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该在相应的
config/environment/development.rb
和production.rb
中设置邮件主机。但是,如果您确实需要像这样内联执行此操作,只需在 Rails.env 上使用条件即可:
You should setup your mail host in the respective
config/environment/development.rb
andproduction.rb
.However, if you really need to do it inline like that, just use a conditional on Rails.env: