Class: MailAutoconfig::EmailAddress
- Inherits:
-
Object
- Object
- MailAutoconfig::EmailAddress
- Defined in:
- lib/mail_autoconfig/email_address.rb
Overview
Email address that we're going to investigate
Instance Method Summary (collapse)
-
- (MailAutoconfig::ClientConfig) client_config
Fetch the client configuration for this email address.
-
- (String) domain
The domain of the email address (the part after the @ symbol).
-
- (EmailAddress) initialize(address)
constructor
A new instance of EmailAddress.
-
- (String) local_part
The local part of the emai address (before the @ symbol).
-
- (String) primary_mx_domain
Finds the primary MX domain for this address.
Constructor Details
- (EmailAddress) initialize(address)
Returns a new instance of EmailAddress
7 8 9 |
# File 'lib/mail_autoconfig/email_address.rb', line 7 def initialize(address) @address = address end |
Instance Method Details
- (MailAutoconfig::ClientConfig) client_config
Fetch the client configuration for this email address. First of all try the domain determined by #domain. If nothing is found there, check the domain specified in #primary_mx_domain. Returns false if none found.
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/mail_autoconfig/email_address.rb', line 15 def client_config return @client_config if @client_config @client_config = MailAutoconfig::ClientConfig.search(domain) unless @client_config @client_config = MailAutoconfig::ClientConfig.search(primary_mx_domain) end @client_config end |
- (String) domain
The domain of the email address (the part after the @ symbol)
35 36 37 |
# File 'lib/mail_autoconfig/email_address.rb', line 35 def domain @domain ||= @address.split('@', 2).last end |
- (String) local_part
The local part of the emai address (before the @ symbol). Useful for usage with the %EMAILLOCALPART% substitution.
29 30 31 |
# File 'lib/mail_autoconfig/email_address.rb', line 29 def local_part @local_part ||= @address.split('@', 2).first end |
- (String) primary_mx_domain
Finds the primary MX domain for this address. Would change gmail-smtp-in.l.google.com to google.com
41 42 43 |
# File 'lib/mail_autoconfig/email_address.rb', line 41 def primary_mx_domain mx_records.first.split(".")[-2..-1].join(".") # Not very nice to 2nd level domains end |