chrismccord / mailgun

Elixir Mailgun Client
MIT License
194 stars 95 forks source link

Add an option for file content as a string in an attachment Map #28

Closed vysakh0 closed 8 years ago

vysakh0 commented 8 years ago

Previously, we could send an attachment like this

attachments: [%{path: "/tmp/image.png", filename: "img.png"}]

When one is generating a pdf or any files on the fly, one has to write this as a temporary file in some place before sending it as an attachment.

So with this, one could also send the file content like this


def send_greetings(user, file_path) do
    file_content = File.read!(file_path)
    send_email to: user.email,
               from: @from,
               subject: "Happy b'day",
               html: "<strong>Cheers!</strong>",
              attachments: [%{content: file_content, filename: "img.png"}]
end
chrismccord commented 8 years ago

This looks great! Can you add a section to the @moduledoc about sending attachments in general, the options, and include this new feature in the examples?

vysakh0 commented 8 years ago

Sure :+1:

vysakh0 commented 8 years ago

I've added the moduledoc, can you please take a look? screenshot from 2015-11-29 20 51 05 screenshot from 2015-11-29 20 52 13

vysakh0 commented 8 years ago

@chrismccord There wasn't an existing @moduledoc, so added few examples that were part of README, please review if it is okay.

chrismccord commented 8 years ago

<3 <3 <3

vysakh0 commented 8 years ago

Wow, awesome, I was hesitant to give pull request at first (bit embarrassed about the code) thank you @optikfluffel for the nudge and chrismccord for merging :+1:

:heart: :green_heart: :blue_heart: :purple_heart: to the elixir community :+1: