Skip to content

Instantly share code, notes, and snippets.

@guihatano
Last active April 10, 2018 23:24
Show Gist options
  • 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:[email protected]/v2/domain.com/",
:from => "YourDomain <[email protected]>",
:to => "[email protected]",
: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