1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/lib/tasks/ingress.rake

25 lines
726 B
Ruby
Raw Normal View History

# frozen_string_literal: true
namespace :action_mailbox do
namespace :ingress do
2018-11-25 14:30:05 -05:00
desc "Pipe an inbound email from STDIN to the Postfix ingress (URL and INGRESS_PASSWORD required)"
task :postfix do
require "active_support"
require "active_support/core_ext/object/blank"
2018-11-25 19:26:00 -05:00
require "action_mailbox/postfix_relayer"
2018-11-25 21:35:27 -05:00
url, password = ENV.values_at("URL", "INGRESS_PASSWORD")
if url.blank? || password.blank?
2018-11-25 19:29:46 -05:00
print "4.3.5 URL and INGRESS_PASSWORD are required"
exit 1
end
2018-11-25 21:35:27 -05:00
ActionMailbox::PostfixRelayer.new(url: url, password: password).relay(STDIN.read).tap do |result|
print result.output
exit result.success? ? 0 : 1
end
end
end
end