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: "hello@xxxxx.co",
subject: "Hello world",
text: "Welcome to Mailchimp Transactional!",
to: [
{
email: "xxxxxx@gmail.com",
type: "to"
}
]
}
begin
response = client.messages.send(message)
p response
rescue MailchimpTransactional::ApiError => e
puts "Error: #{e}"
end
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.