简体   繁体   中英

How to use Mailgun with HTTParty in Rails

I want to use Mailgun with HTTParty in Rails:

RestClient.post "https://api:key-###"\
    "@api.mailgun.net/v3/###/messages",
    from: from_email,
    to: to_email,
    subject: title,
    html: body_text

It's working but

payload = {
    from: email_history.from_email,
    to: email_history.to_email,
    subject: email_history.title,
    html: email_history.body_text,
    multipart: true
}

response = SendEmailJob.post('https://api:key-###'\
'@api.mailgun.net/v3/###/messages', payload)

Returns:

{
  "message": "'from' parameter is missing"
}

I checked and the payload "from" parameter exists.

How can I fix this?

I solved this by adding the body:

SendEmailJob.post('api:key-###'\ '@api.mailgun.net/v3/###/messages', body: payload)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM