Class: Mail::Configuration
- Inherits:
-
Object
- Object
- Mail::Configuration
- Includes:
- Singleton
- Defined in:
- lib/mail/configuration.rb
Overview
The Configuration class is a Singleton used to hold the default configuration for all class wide configurations of Mail.
This includes things like running in Test mode, the POP3, IMAP, SMTP, Sendmail and File delivery method information et al.
See Mail.defaults for more information.
Instance Method Summary collapse
-
#defaults(&block) ⇒ Object
Creates a new Mail::Configuration object through .defaults.
-
#delivery_method(value = nil) ⇒ Object
Allows you to define the delivery method for mail, defaults to SMTP.
- #param_encode_language(value = nil) ⇒ Object
-
#pop3(*args, &block) ⇒ Object
Allows you to specify the POP3 Server by passing the hostname or IP Address as a String with an optional port number as a string or integer.
-
#retriever_method(value = nil) ⇒ Object
Allows you to define the retriever method for mail, defaults to POP3.
- #sendmail(sendmail_path = nil) ⇒ Object
-
#smtp(*args, &block) ⇒ Object
Allows you to specify the SMTP Server by passing the hostname or IP Address as a String with an optional port number as a string or integer.
Instance Method Details
#defaults(&block) ⇒ Object
Creates a new Mail::Configuration object through .defaults
20 21 22 23 24 25 |
# File 'lib/mail/configuration.rb', line 20 def defaults(&block) if block_given? instance_eval(&block) end self end |
#delivery_method(value = nil) ⇒ Object
Allows you to define the delivery method for mail, defaults to SMTP
This can either be a symbol (:smtp, :sendmail, :file, :test) or you can pass in your own delivery class, in which case this will be set.
53 54 55 |
# File 'lib/mail/configuration.rb', line 53 def delivery_method(value = nil) value ? @delivery_method = lookup_delivery_method(value) : @delivery_method ||= Mail::SMTP end |
#param_encode_language(value = nil) ⇒ Object
96 97 98 |
# File 'lib/mail/configuration.rb', line 96 def param_encode_language(value = nil) value ? @encode_language = value : @encode_language ||= 'en' end |
#pop3(*args, &block) ⇒ Object
Allows you to specify the POP3 Server by passing the hostname or IP Address as a String with an optional port number as a string or integer.
Defaults to 127.0.0.1 and port 110.
Example:
Mail.defaults.do
pop3 '127.0.0.1'
end
Mail.defaults do
pop3 '127.0.0.1', 995 do
enable_tls
end
end
74 75 76 77 78 79 |
# File 'lib/mail/configuration.rb', line 74 def pop3(*args, &block) if args.size > 0 host_array = [args[0], (args[1].to_i > 0 ? args[1] : 110)] end set_settings(Mail::POP3, host_array, &block) end |
#retriever_method(value = nil) ⇒ Object
Allows you to define the retriever method for mail, defaults to POP3
This can either be a symbol (:pop3, :imap) or you can pass in your own retriever class, in which case this will be set.
92 93 94 |
# File 'lib/mail/configuration.rb', line 92 def retriever_method(value = nil) value ? @retriever_method = lookup_retriever_method(value) : @retriever_method ||= Mail::POP3 end |
#sendmail(sendmail_path = nil) ⇒ Object
81 82 83 84 85 86 |
# File 'lib/mail/configuration.rb', line 81 def sendmail(sendmail_path = nil) delivery_method :sendmail set_settings(Mail::Sendmail) do path sendmail_path end end |
#smtp(*args, &block) ⇒ Object
Allows you to specify the SMTP Server by passing the hostname or IP Address as a String with an optional port number as a string or integer.
Defaults to 127.0.0.1 and port 25.
Example:
Mail.defaults.do
smtp '127.0.0.1'
end
Mail.defaults do
smtp '127.0.0.1', 25
end
42 43 44 45 46 47 |
# File 'lib/mail/configuration.rb', line 42 def smtp(*args, &block) if args.size > 0 host_array = [args[0], (args[1].to_i > 0 ? args[1] : 25)] end set_settings(Mail::SMTP, host_array, &block) end |