【发布时间】:2014-05-15 13:53:04
【问题描述】:
我正在我的本地主机上进行测试。这是我的 development.rb 文件的 action_mailer 部分:
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.mandrillapp.com",
:port => 587,
:user_name => "my_email@email.com,
:password => ENV['MANDRILL_API_KEY'],
}
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
这里是 action_mailer 文件:
def confirm_email(user, school, email)
@user = user
@school = school
@email = email
@url = 'http://example.com/login'
mail(to: @email, subject: 'Please confirm your additional school email.')
end
这是视图:
<!DOCTYPE html>
<html>
<head>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
</head>
<body>
<h1>Hello <%= @user.first_name %></h1>
<p>
To confirm your additional school, <%= link_to "click here", verify_other_school_path(@school) %>.
</p>
<p>Thanks and have a great day!</p>
</body>
</html>
电子邮件正在正常工作并发送。唯一的问题是为链接生成的 html 看起来像:
<a href="http://verifyotherschool/4" target="_blank">click here</a>
而不是应有的方式:
<a href="http://localhost:3000/verifyotherschool/4" target="_blank">click here</a>
我该如何解决这个问题?
【问题讨论】:
标签: ruby-on-rails ruby smtp actionmailer mandrill