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
- VERSION =
"0.1.1"
- 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
.exist?(email) ⇒ Boolean
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/email_detected.rb', line 11
def self.exist?(email)
return true if config.test_mode
return { status: false, message: 'The email address invalid.' } unless email.match VALID_EMAIL_REGEX
email_detected = EmailDetected::Checker.run(email)
if email_detected.invalid?
resp = { status: false, message: email_detected.errors.first }
else
resp = { status: true, message: 'The email address has already been registered.' }
end
resp
end
|