Ruby on Rails mailgun发送带API的邮件失败

时间:2016-03-01 05:26:28

标签: ruby-on-rails ruby-on-rails-4 mailgun

我正在尝试使用mailgun api发送邮件,但我总是收到BAD REQUEST 400错误。相应的代码是

 data = Multimap.new
    data[:from] = "Excited User <postmaster@mydomain.mailgun.org"
    data[:to] = "foo@bar.com"
    data[:subject] = "Hello"
    data[:text] = "Testing some Mailgun awesomness!"  
    RestClient.post "https://api:my-key"\
    "@api.mailgun.net/v3/mydomain/messages", data 

如果我将代码重写为

  RestClient.post "https://api:my-key"\
  "@api.mailgun.net/v3/mydomain/messages",
  :from => "Mailgun Sandbox <postmaster@mydomain.mailgun.org>",
  :to => "foo@bar.com",
  :subject => "Hello",
  :text => "Testing some Mailgun awesomness!"

它有效,但我想添加附件,HTML等。我在这里错过了什么吗?

0 个答案:

没有答案