Module: EmailDetected
- Defined in:
- lib/email_detected.rb,
lib/email_detected/config.rb,
lib/email_detected/version.rb,
lib/email_detected/messages.rb
Defined Under Namespace
Modules: Config
Classes: Checker
Constant Summary
collapse
- VALID_EMAIL_REGEX =
/\A[\w+\-.]+@[a-z\d\-]+(\.[a-z\d\-]+)*\.[a-z]+\z/i.freeze
- VERSION =
"0.1.3"
- MESSAGES =
{
-1 => 'Validation failed (non-SMTP)',
250 => 'Requested mail action okay, completed',
251 => 'User not local; will forward to <forward-path>',
550 => 'Requested action not taken:, mailbox unavailable',
551 => 'User not local; please try <forward-path>',
552 => 'Requested mail action aborted:, exceeded storage allocation',
553 => 'Requested action not taken:, mailbox name not allowed',
450 => 'Requested mail action not taken:, mailbox unavailable',
451 => 'Requested action aborted:, local error in processing',
452 => 'Requested action not taken:, insufficient system storage',
500 => 'Syntax error, command unrecognised',
501 => 'Syntax error in parameters or arguments',
503 => 'Bad sequence of commands',
521 => '<domain> does not accept mail [rfc1846]',
421 => '<domain> Service not available, closing transmission channel'
}
Class Method Summary
collapse
Class Method Details
.config(&block) ⇒ Object
29
30
31
32
33
34
35
|
# File 'lib/email_detected.rb', line 29
def self.config(&block)
if block_given?
block.call(EmailDetected::Config)
else
EmailDetected::Config
end
end
|
.exist?(email) ⇒ Boolean
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/email_detected.rb', line 13
def self.exist?(email)
return true if config.test_mode
unless email.match VALID_EMAIL_REGEX
return { status: false, message: 'The email address invalid.' }
end
email_detected = EmailDetected::Checker.run(email)
if email_detected.invalid?
resp = { status: false, message: email_detected.errors.first }
else
message = email_detected.errors.first || 'The email address has already been registered.'
resp = { status: true, message: message }
end
resp
end
|