From c0e26f5ba6816345dac9280d82bc4f007e2eeea2 Mon Sep 17 00:00:00 2001 From: nikkel Date: Fri, 20 Mar 2020 03:32:30 +0700 Subject: [PATCH] Upload files to 'lib/postman/rails' --- .../rails/action_mailer_delivery_method.rb | 31 +++++++++++++++++++ lib/postman/rails/version.rb | 5 +++ 2 files changed, 36 insertions(+) create mode 100644 lib/postman/rails/action_mailer_delivery_method.rb create mode 100644 lib/postman/rails/version.rb diff --git a/lib/postman/rails/action_mailer_delivery_method.rb b/lib/postman/rails/action_mailer_delivery_method.rb new file mode 100644 index 0000000..8fdd1fa --- /dev/null +++ b/lib/postman/rails/action_mailer_delivery_method.rb @@ -0,0 +1,31 @@ +module Postman + module Rails + class ActionMailerDeliveryMethod + + def initialize(settings) + @settings = settings + end + + def settings + @settings + end + + def deliver!(message) + client.send_raw_message do |m| + m.mail_from(message.from.first) + [message.to, message.cc, message.bcc].flatten.compact.uniq.each do |address| + m.rcpt_to(address) + end + m.data(message.to_s) + end + end + + private + + def client + @client ||= Postman::Client.new(@settings[:host] || ENV['POSTMAN_HOST'], @settings[:server_key] || ENV['POSTMAN_KEY']) + end + + end + end +end diff --git a/lib/postman/rails/version.rb b/lib/postman/rails/version.rb new file mode 100644 index 0000000..551fec5 --- /dev/null +++ b/lib/postman/rails/version.rb @@ -0,0 +1,5 @@ +module Postman + module Rails + VERSION = '1.0.1' + end +end