email_detected 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +35 -4
- data/lib/email_detected/version.rb +1 -1
- data/lib/email_detected.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 347e647a4741ba319e4af10c64e7efd367bf8d5d
|
4
|
+
data.tar.gz: 1267dab70b3fbdce14049bed1380978ad0c67494
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 447f8551a3cf83e5dfe843a6d70e073980ed1c8459f2ac9761c1811c0d2ce5a349af17a491578dbb70482b246123e3696cdf9f00bef82caeeb68aafcec1b3654
|
7
|
+
data.tar.gz: b0e2086071e5f9a358334402b3b943c31a6ef68c47510fe5baf1fbb306cbdd771e3e5007792741b4474f227bce2d4e34046d4440d52ed9cfb5d96fa70e37cd1d
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
#
|
1
|
+
# Email Detected
|
2
2
|
|
3
|
-
|
3
|
+
Email Detected is a simple tool for verifying an email address exists. It's free and quite easy to use :smile: .
|
4
4
|
|
5
|
-
|
5
|
+
Many times as developers we were putting validation statements for checking email addresses format. This gem will complete your existing setups with validator that actually connects with a given mail server and asks if the address in question exists for real.
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -22,7 +22,38 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
|
25
|
+
To get info about realness of given email address, email_detected connects with a mail server that email's domain points to and pretends to send an email. Some smtp servers will not allow you to do this if you will not present yourself as a real user.
|
26
|
+
|
27
|
+
This only needs to be something the receiving SMTP server. We aren't actually sending any mail.
|
28
|
+
|
29
|
+
First thing you need to set up is placing something like this either in initializer or in application.rb file:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
EmailDetected.config do |config|
|
33
|
+
config.verifier_email = "quannguyen@bestcoder.info"
|
34
|
+
end
|
35
|
+
```
|
36
|
+
|
37
|
+
Then just put this in your model e. g:
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
validates_exist_email_of :email
|
41
|
+
```
|
42
|
+
Or - if you'd like to use it outside of your models:
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
EmailDetected.exist?(youremail)
|
46
|
+
```
|
47
|
+
|
48
|
+
This method will return with status `true || false` and `message` look like:
|
49
|
+
```
|
50
|
+
{:status=>true, :message=>"The email address has already been registered."}
|
51
|
+
```
|
52
|
+
|
53
|
+
```
|
54
|
+
{:status=>false, :message=>"The email address invalid."}
|
55
|
+
```
|
56
|
+
or will throw an exception with nicely detailed info about what's wrong.
|
26
57
|
|
27
58
|
## Development
|
28
59
|
|
data/lib/email_detected.rb
CHANGED
@@ -10,7 +10,7 @@ module EmailDetected
|
|
10
10
|
|
11
11
|
def self.exist?(email)
|
12
12
|
return true if config.test_mode
|
13
|
-
return { status: false,
|
13
|
+
return { status: false, message: 'The email address invalid.' } unless email.match VALID_EMAIL_REGEX
|
14
14
|
email_detected = EmailDetected::Checker.run(email)
|
15
15
|
if email_detected.invalid?
|
16
16
|
resp = { status: false, message: email_detected.errors.first }
|