Class: MailAutoconfig::Server
- Inherits:
-
Object
- Object
- MailAutoconfig::Server
- Defined in:
- lib/mail_autoconfig/server.rb
Overview
Superclass for IncomingServer and OutgoingServer. Never used directly.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#client_config ⇒ Object
readonly
Returns the value of attribute client_config.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#authentication ⇒ String
The authentication type for this server.
-
#hostname ⇒ String
The hostname for this server.
-
#initialize(config, client_config) ⇒ Server
constructor
A new instance of Server.
-
#port ⇒ Integer
The port to connect ot this server on.
-
#protocol ⇒ String
Returns the protocol of the mail server e.g.
-
#socket_type ⇒ String
The connection type for this server.
-
#username ⇒ String
The username for this mailbox, combines #username_format and [EmailAddress] details.
-
#username_format ⇒ String
Return the username format for this server.
Constructor Details
#initialize(config, client_config) ⇒ Server
Returns a new instance of Server.
9 10 11 12 |
# File 'lib/mail_autoconfig/server.rb', line 9 def initialize(config, client_config) @config = config @client_config = client_config end |
Instance Attribute Details
#client_config ⇒ Object (readonly)
Returns the value of attribute client_config.
6 7 8 |
# File 'lib/mail_autoconfig/server.rb', line 6 def client_config @client_config end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
5 6 7 |
# File 'lib/mail_autoconfig/server.rb', line 5 def config @config end |
Instance Method Details
#authentication ⇒ String
The authentication type for this server. Valid responses:
password-cleartext
, NTLM
, GSSAPI
, client-IP-address
, TLS-client-cert
, none
62 63 64 |
# File 'lib/mail_autoconfig/server.rb', line 62 def authentication @authentication ||= config.xpath("authentication").first.content end |
#hostname ⇒ String
Returns The hostname for this server.
21 22 23 |
# File 'lib/mail_autoconfig/server.rb', line 21 def hostname @hostname ||= config.xpath("hostname").first.content end |
#port ⇒ Integer
Returns The port to connect ot this server on.
26 27 28 |
# File 'lib/mail_autoconfig/server.rb', line 26 def port @port ||= config.xpath("port").first.content.to_i end |
#protocol ⇒ String
Returns the protocol of the mail server e.g. smtp
, pop3
, imap
16 17 18 |
# File 'lib/mail_autoconfig/server.rb', line 16 def protocol @protocol ||= config.attr("type") end |
#socket_type ⇒ String
The connection type for this server. plain
, STARTTLS
, SSL
are acceptable
32 33 34 |
# File 'lib/mail_autoconfig/server.rb', line 32 def socket_type @socket_type ||= config.xpath("socketType").first.content end |
#username ⇒ String
The username for this mailbox, combines #username_format and [EmailAddress] details
38 39 40 41 42 43 44 45 46 |
# File 'lib/mail_autoconfig/server.rb', line 38 def username @username ||= begin name = username_format name.gsub! "%EMAILADDRESS%", client_config.email_address.address name.gsub! "%EMAILLOCALPART%", client_config.email_address.local_part name.gsub! "%EMAILDOMAIN%", client_config.email_address.domain name end end |
#username_format ⇒ String
Return the username format for this server. There are substitutions that can be made.
%EMAILADDRESS%
- full email address of the user, usually entered by the user%EMAILLOCALPART%
- email address, part before @%EMAILDOMAIN%
- email address, part after @
55 56 57 |
# File 'lib/mail_autoconfig/server.rb', line 55 def username_format @username_format ||= config.xpath("username").first.content end |