在模型中连接邮件服务时放置邮件模板的位置

时间:2014-08-24 19:09:22

标签: ruby-on-rails web-services email ruby-on-rails-4

我使用下面的示例方法连接到我的模型中的邮件提供商API。

由于HTML内容相当复杂,构建邮件的位置比方法中的内联更好?

def send_message(variables)
  data = Multimap.new
  data[:from] = "Excited User <me@example.com>"
  data[:to] = "foo@example.com"
  data[:subject] = "Today is the day"
  data[:text] = "Hey, %recipient.first%"
  data[:html] = "<html>Hey, %recipient.first%</html>"
  data[:recipient-variables] = '{"bob@example.com": {"first":"Bob", "id":1}, "alice@example.com": {"first":"Alice", "id": 2}}'
  RestClient.post "https://example.com/api", data
end

0 个答案:

没有答案