Class: MailAutoconfig::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/mail_autoconfig/server.rb

Overview

Superclass for IncomingServer and OutgoingServer. Never used directly.

Direct Known Subclasses

IncomingServer, OutgoingServer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, client_config) ⇒ Server

Returns a new instance of Server.

Parameters:

  • config (Nokogiri::XML::Node)

    an XML representation of this server



10
11
12
13
# File 'lib/mail_autoconfig/server.rb', line 10

def initialize(config, client_config)
  @config = config
  @client_config = client_config
end

Instance Attribute Details

#client_configObject (readonly)

Returns the value of attribute client_config.



7
8
9
# File 'lib/mail_autoconfig/server.rb', line 7

def client_config
  @client_config
end

#configObject (readonly)

Returns the value of attribute config.



6
7
8
# File 'lib/mail_autoconfig/server.rb', line 6

def config
  @config
end

Instance Method Details

#authenticationString

The authentication type for this server. Valid responses: password-cleartext, NTLM, GSSAPI, client-IP-address, TLS-client-cert, none

Returns:

  • (String)

    the authentication method for this server



63
64
65
# File 'lib/mail_autoconfig/server.rb', line 63

def authentication
  @authentication ||= config.xpath('authentication').first.content
end

#hostnameString

Returns The hostname for this server.

Returns:

  • (String)

    The hostname for this server



22
23
24
# File 'lib/mail_autoconfig/server.rb', line 22

def hostname
  @hostname ||= config.xpath('hostname').first.content
end

#portInteger

Returns The port to connect ot this server on.

Returns:

  • (Integer)

    The port to connect ot this server on



27
28
29
# File 'lib/mail_autoconfig/server.rb', line 27

def port
  @port ||= config.xpath('port').first.content.to_i
end

#protocolString

Returns the protocol of the mail server e.g. smtp, pop3, imap

Returns:

  • (String)

    The protocol for the server



17
18
19
# File 'lib/mail_autoconfig/server.rb', line 17

def protocol
  @protocol ||= config.attr('type')
end

#socket_typeString

The connection type for this server. plain, STARTTLS, SSL are acceptable

Returns:

  • (String)

    The connection type



33
34
35
# File 'lib/mail_autoconfig/server.rb', line 33

def socket_type
  @socket_type ||= config.xpath('socketType').first.content
end

#usernameString

The username for this mailbox, combines #username_format and [EmailAddress] details

Returns:

  • (String)

    The username



39
40
41
42
43
44
45
46
47
# File 'lib/mail_autoconfig/server.rb', line 39

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_formatString

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 @

Returns:

  • (String)

    the username format



56
57
58
# File 'lib/mail_autoconfig/server.rb', line 56

def username_format
  @username_format ||= config.xpath('username').first.content
end