我正在尝试使用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等。我在这里错过了什么吗?