我使用下面的示例方法连接到我的模型中的邮件提供商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