Module: Postmark
- Defined in:
- lib/postmark/response_parsers/active_support.rb,
lib/postmark.rb,
lib/postmark/json.rb,
lib/postmark/bounce.rb,
lib/postmark/http_client.rb,
lib/postmark/response_parsers/json.rb,
lib/postmark/response_parsers/yajl.rb,
lib/postmark/attachments_fix_for_mail.rb,
lib/postmark/message_extensions/shared.rb
Overview
assume activesupport is already loaded
Defined Under Namespace
Modules: AttachmentsFixForMail, HttpClient, Json, ResponseParsers, SharedMessageExtensions Classes: Bounce, InternalServerError, InvalidApiKeyError, InvalidMessageError, UnknownError, UnknownMessageType
Constant Summary
- HEADERS =
{ 'Content-type' => 'application/json', 'Accept' => 'application/json' }
- MAX_RETRIES =
2
Class Attribute Summary (collapse)
-
+ (Object) api_key
Returns the value of attribute api_key.
-
+ (Object) host
The host to connect to.
-
+ (Object) http_open_timeout
Returns the value of attribute http_open_timeout.
-
+ (Object) http_read_timeout
Returns the value of attribute http_read_timeout.
-
+ (Object) max_retries
Returns the value of attribute max_retries.
-
+ (Object) path_prefix
The path of the listener.
-
+ (Object) port
The port on which your Postmark server runs.
-
+ (Object) proxy_host
Returns the value of attribute proxy_host.
-
+ (Object) proxy_pass
Returns the value of attribute proxy_pass.
-
+ (Object) proxy_port
Returns the value of attribute proxy_port.
-
+ (Object) proxy_user
Returns the value of attribute proxy_user.
- + (Object) response_parser_class
-
+ (Object) secure
Returns the value of attribute secure.
-
+ (Object) sleep_between_retries
Returns the value of attribute sleep_between_retries.
Class Method Summary (collapse)
- + (Object) configure {|_self| ... }
- + (Object) convert_message_to_options_hash(message)
- + (Object) delivery_stats
-
+ (Object) send_through_postmark(message)
:nodoc:.
Class Attribute Details
+ (Object) api_key
Returns the value of attribute api_key
39 40 41 |
# File 'lib/postmark.rb', line 39 def api_key @api_key end |
+ (Object) host
The host to connect to.
54 55 56 |
# File 'lib/postmark.rb', line 54 def host @host ||= 'api.postmarkapp.com' end |
+ (Object) http_open_timeout
Returns the value of attribute http_open_timeout
39 40 41 |
# File 'lib/postmark.rb', line 39 def http_open_timeout @http_open_timeout ||= 5 end |
+ (Object) http_read_timeout
Returns the value of attribute http_read_timeout
39 40 41 |
# File 'lib/postmark.rb', line 39 def http_read_timeout @http_read_timeout ||= 15 end |
+ (Object) max_retries
Returns the value of attribute max_retries
39 40 41 |
# File 'lib/postmark.rb', line 39 def max_retries @max_retries ||= 3 end |
+ (Object) path_prefix
The path of the listener
59 60 61 |
# File 'lib/postmark.rb', line 59 def path_prefix @path_prefix ||= '/' end |
+ (Object) port
The port on which your Postmark server runs.
49 50 51 |
# File 'lib/postmark.rb', line 49 def port @port || (secure ? 443 : 80) end |
+ (Object) proxy_host
Returns the value of attribute proxy_host
39 40 41 |
# File 'lib/postmark.rb', line 39 def proxy_host @proxy_host end |
+ (Object) proxy_pass
Returns the value of attribute proxy_pass
39 40 41 |
# File 'lib/postmark.rb', line 39 def proxy_pass @proxy_pass end |
+ (Object) proxy_port
Returns the value of attribute proxy_port
39 40 41 |
# File 'lib/postmark.rb', line 39 def proxy_port @proxy_port end |
+ (Object) proxy_user
Returns the value of attribute proxy_user
39 40 41 |
# File 'lib/postmark.rb', line 39 def proxy_user @proxy_user end |
+ (Object) response_parser_class
44 45 46 |
# File 'lib/postmark.rb', line 44 def response_parser_class @response_parser_class ||= Object.const_defined?(:ActiveSupport) ? :ActiveSupport : :Json end |
+ (Object) secure
Returns the value of attribute secure
39 40 41 |
# File 'lib/postmark.rb', line 39 def secure @secure end |
+ (Object) sleep_between_retries
Returns the value of attribute sleep_between_retries
39 40 41 |
# File 'lib/postmark.rb', line 39 def sleep_between_retries @sleep_between_retries ||= 10 end |
Class Method Details
+ (Object) configure {|_self| ... }
79 80 81 |
# File 'lib/postmark.rb', line 79 def configure yield self end |
+ (Object) convert_message_to_options_hash(message)
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/postmark.rb', line 97 def () = Hash.new headers = () ["From"] = ['from'].to_s if .from ["ReplyTo"] = .reply_to.join(", ") if .reply_to ["To"] = .to.join(", ") if .to ["Cc"] = .cc.join(", ") if .cc ["Bcc"] = .bcc.join(", ") if .bcc ["Subject"] = .subject ["Attachments"] = . ["Tag"] = .tag.to_s if .tag ["Headers"] = headers if headers.size > 0 = .delete_if{|k,v| v.nil?} html = .body_html text = .body_text if .multipart? ["HtmlBody"] = html ["TextBody"] = text elsif html ["HtmlBody"] = html else ["TextBody"] = text end end |
+ (Object) delivery_stats
128 129 130 |
# File 'lib/postmark.rb', line 128 def delivery_stats HttpClient.get("deliverystats") end |
+ (Object) send_through_postmark(message)
:nodoc:
83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/postmark.rb', line 83 def send_through_postmark() #:nodoc: @retries = 0 begin HttpClient.post("email", Postmark::Json.encode(())) rescue Exception => e if @retries < max_retries @retries += 1 retry else raise end end end |