Sha256: 2161c5c80729bb444eb22d93b9a4be1d26abf5aa90073a1fb495e6c658c5576c
Contents?: true
Size: 1 KB
Versions: 1
Compression:
Stored size: 1 KB
Contents
require 'rest_client' require 'monkey_mail/clients/base_client' module MonkeyMail module Clients class MailgunClient < BaseClient attr_reader :api_key, :domain def initialize(api_key, domain) @api_key = api_key @domain = domain end def send_template(template_name:, subject:, from_email:, from_name:, to:, vars:, attachment: nil) payload = { :from => "#{from_name} <#{from_email}>", :to => to.join(', '), :subject => subject, :template => template_name, :attachment => attachment, 't:variables' => vars.to_json } RestClient::Request.execute(method: :post, url: messages_url, payload: payload) end private def messages_url "#{api_url}/messages" end def api_url "https://api:#{api_key}@api.mailgun.net/v3/#{domain}" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
monkey-mail-0.1.1 | lib/monkey_mail/clients/mailgun_client.rb |