Class: ActionMailbox::PostfixRelayer
- Inherits:
-
Object
- Object
- ActionMailbox::PostfixRelayer
- Defined in:
- lib/action_mailbox/postfix_relayer.rb
Defined Under Namespace
Classes: Result
Constant Summary collapse
- CONTENT_TYPE =
"message/rfc822"- USER_AGENT =
"Action Mailbox Postfix relayer v#{ActionMailbox::VERSION}"
Instance Attribute Summary collapse
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
-
#initialize(url:, username: "actionmailbox", password:) ⇒ PostfixRelayer
constructor
A new instance of PostfixRelayer.
- #relay(source) ⇒ Object
Constructor Details
#initialize(url:, username: "actionmailbox", password:) ⇒ PostfixRelayer
Returns a new instance of PostfixRelayer.
24 25 26 |
# File 'lib/action_mailbox/postfix_relayer.rb', line 24 def initialize(url:, username: "actionmailbox", password:) @uri, @username, @password = URI(url), username, password end |
Instance Attribute Details
#password ⇒ Object (readonly)
Returns the value of attribute password.
22 23 24 |
# File 'lib/action_mailbox/postfix_relayer.rb', line 22 def password @password end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
22 23 24 |
# File 'lib/action_mailbox/postfix_relayer.rb', line 22 def uri @uri end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
22 23 24 |
# File 'lib/action_mailbox/postfix_relayer.rb', line 22 def username @username end |
Instance Method Details
#relay(source) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/action_mailbox/postfix_relayer.rb', line 28 def relay(source) case response = post(source) when Net::HTTPSuccess Result.new "2.0.0 Successfully relayed message to Postfix ingress" when Net:: Result.new "4.7.0 Invalid credentials for Postfix ingress" else Result.new "4.0.0 HTTP #{response.code}" end rescue IOError, SocketError, SystemCallError => error Result.new "4.4.2 Network error relaying to Postfix ingress: #{error.message}" rescue Timeout::Error Result.new "4.4.2 Timed out relaying to Postfix ingress" rescue => error Result.new "4.0.0 Error relaying to Postfix ingress: #{error.message}" end |