mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Always emit enhanced SMTP status codes
This commit is contained in:
parent
6608bf60aa
commit
ac7fd0e568
1 changed files with 12 additions and 11 deletions
|
@ -9,31 +9,32 @@ namespace :action_mailbox do
|
||||||
require "http"
|
require "http"
|
||||||
|
|
||||||
unless url = ENV["URL"].presence
|
unless url = ENV["URL"].presence
|
||||||
abort "URL is required"
|
abort "5.3.5 URL is required"
|
||||||
end
|
end
|
||||||
|
|
||||||
unless password = ENV["INGRESS_PASSWORD"].presence
|
unless password = ENV["INGRESS_PASSWORD"].presence
|
||||||
abort "INGRESS_PASSWORD is required"
|
abort "5.3.5 INGRESS_PASSWORD is required"
|
||||||
end
|
end
|
||||||
|
|
||||||
begin
|
begin
|
||||||
response = HTTP.basic_auth(user: "actionmailbox", pass: password)
|
response = HTTP.basic_auth(user: "actionmailbox", pass: password)
|
||||||
.timeout(connect: 1, write: 10, read: 10)
|
.timeout(connect: 1, write: 10, read: 10)
|
||||||
.post(url, headers: { "Content-Type" => "message/rfc822", "User-Agent" => "Postfix" }, body: STDIN)
|
.post(url, headers: { "Content-Type" => "message/rfc822", "User-Agent" => ENV.fetch("USER_AGENT", "Postfix") }, body: STDIN)
|
||||||
|
|
||||||
if response.status.success?
|
case
|
||||||
|
when response.status.success?
|
||||||
puts "2.0.0 HTTP #{response.status}"
|
puts "2.0.0 HTTP #{response.status}"
|
||||||
exit 0
|
when response.status.unauthorized?
|
||||||
|
abort "4.7.0 HTTP #{response.status}"
|
||||||
|
when response.status.unsupported_media_type?
|
||||||
|
abort "5.6.1 HTTP #{response.status}"
|
||||||
else
|
else
|
||||||
puts "4.6.0 HTTP #{response.status}"
|
abort "4.0.0 HTTP #{response.status}"
|
||||||
exit 1
|
|
||||||
end
|
end
|
||||||
rescue HTTP::ConnectionError => error
|
rescue HTTP::ConnectionError => error
|
||||||
puts "4.4.2 Error connecting to the Postfix ingress: #{error.message}"
|
abort "4.4.2 Error connecting to the Postfix ingress: #{error.message}"
|
||||||
exit 1
|
|
||||||
rescue HTTP::TimeoutError
|
rescue HTTP::TimeoutError
|
||||||
puts "4.4.7 Timed out piping to the Postfix ingress"
|
abort "4.4.7 Timed out piping to the Postfix ingress"
|
||||||
exit 1
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue