Class: MailPlugger::DeliveryMethod
- Inherits:
-
Object
- Object
- MailPlugger::DeliveryMethod
- Includes:
- MailHelper
- Defined in:
- lib/mail_plugger/delivery_method.rb
Direct Known Subclasses
Constant Summary
Constants included from MailHelper
MailHelper::DELIVERY_SETTINGS_KEYS, MailHelper::SENDING_METHODS
Instance Method Summary collapse
-
#deliver!(message) ⇒ Mail::Message/Hash
Using SMTP: Send message via SMTP protocol if the ‘delivery_settings’ contains a ‘smtp_settings’ key and the value is a hash with the settings.
-
#initialize(options = {}) ⇒ DeliveryMethod
constructor
Initialize delivery method attributes.
Methods included from MailHelper
#check_version_of, #client, #default_data, #default_delivery_system_get, #delivery_data, #delivery_options, #delivery_system, #delivery_system_value_check, #exclude_delivey_settings_keys?, #extract_attachments, #extract_keys, #extract_keys_from_other_variables, #mail_field_value, #message_field_value_from, #need_delivery_system?, #option_value_from, #send_via_smtp?, #sending_method_get, #settings
Constructor Details
#initialize(options = {}) ⇒ DeliveryMethod
Initialize delivery method attributes. If we are using MailPlugger.plug_in method, then these attributes can be nil, if not then we should set these attributes.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/mail_plugger/delivery_method.rb', line 24 def initialize( = {}) @client = [:client] || MailPlugger.client = [:delivery_options] || MailPlugger. @delivery_settings = [:delivery_settings] || MailPlugger.delivery_settings @passed_default_delivery_system = [:default_delivery_system] || MailPlugger.default_delivery_system # ----------------------------------------------------------------------- = MailPlugger. @delivery_systems = MailPlugger.delivery_systems @rotatable_delivery_systems = MailPlugger.rotatable_delivery_systems @sending_method = MailPlugger.sending_method # ----------------------------------------------------------------------- @default_delivery_system = default_delivery_system_get = nil end |
Instance Method Details
#deliver!(message) ⇒ Mail::Message/Hash
Using SMTP: Send message via SMTP protocol if the ‘delivery_settings’ contains a ‘smtp_settings’ key and the value is a hash with the settings.
Using API: Send message with the given client if the message parameter is a Mail::Message object. Before doing that, extract this information from the Mail::Message object which was provided in the ‘delivery_options’. After that it generates a hash with these data and sends the message with the provided client class which has a ‘deliver’ method.
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/mail_plugger/delivery_method.rb', line 133 def deliver!() unless .is_a?(Mail::Message) raise Error::WrongParameter, 'The given parameter is not a Mail::Message' end = if send_via_smtp? .delivery_method :smtp, settings[:smtp_settings] .deliver! else client.new(delivery_data).deliver end end |