无法从Ruby上的Mandrill发送邮件

发布于 2025-01-28 23:26:12 字数 1146 浏览 4 评论 0原文

您好,我是Ruby on Rails上的新手,我正在尝试从Mandrill发送邮件,然后遵循此文档 https://mailchimp.com/developer/transactional/guides/guides/send-first-email/ 但是我以某种方式遇到这个错误,

Error: {:status=>500, :response_body=>"{\"status\":\"error\",\"code\":-1,\"name\":\"ValidationError\",\"message\":\"You must specify a message value\"}"}

这是我的代码

client = MailchimpTransactional::Client.new('xxxxxxxxxRWX-nA')
message = {
  from_email: "[email protected]",
  subject: "Hello world",
  text: "Welcome to Mailchimp Transactional!",
  to: [
    {
      email: "[email protected]",
      type: "to"
    }
  ]
}

begin
  response = client.messages.send(message)
  p response
rescue MailchimpTransactional::ApiError => e
  puts "Error: #{e}"
end

Hello I am newbie to ruby on rails, I am trying to send mail from mandrill and following this documentation https://mailchimp.com/developer/transactional/guides/send-first-email/
but somehow I am getting this error

Error: {:status=>500, :response_body=>"{\"status\":\"error\",\"code\":-1,\"name\":\"ValidationError\",\"message\":\"You must specify a message value\"}"}

here is my code

client = MailchimpTransactional::Client.new('xxxxxxxxxRWX-nA')
message = {
  from_email: "[email protected]",
  subject: "Hello world",
  text: "Welcome to Mailchimp Transactional!",
  to: [
    {
      email: "[email protected]",
      type: "to"
    }
  ]
}

begin
  response = client.messages.send(message)
  p response
rescue MailchimpTransactional::ApiError => e
  puts "Error: #{e}"
end

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

做个少女永远怀春 2025-02-04 23:26:12

这是因为您必须将其传递给客户,并具有以下消息的关键值:

这是不正确的:

response = client.messages.send(message)

这是正确的:

response = client.messages.send(message: message)

mailchimp的网站不正确。

That's because you have to pass it to the client with a key value of message as follows:

This is incorrect:

response = client.messages.send(message)

This is correct:

response = client.messages.send(message: message)

The transactional email documentation on Mailchimp's website is incorrect.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文