Skip to content

Instantly share code, notes, and snippets.

@guihatano
Last active April 10, 2018 23:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guihatano/7f5dff665cfce53fd0b0a8c915d0d791 to your computer and use it in GitHub Desktop.
Save guihatano/7f5dff665cfce53fd0b0a8c915d0d791 to your computer and use it in GitHub Desktop.
Rails using RestClient to call mailgun with attachment. When I was searching I just found same ways using RestClient::Request.execute, so I'm sharing this other way
require 'json'
result = RestClient.post "https://api:key-xxxxxxxxx-xxxxxxx@api.mailgun.net/v2/domain.com/",
:from => "YourDomain <your-email@domain.com>",
:to => "to-email@email.com",
:subject => "Mailgun with attachment",
:text => "Hello, Put something here",
:multipart => true,
:attachment => File.new('path/to/file', 'rb')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment