egalite 1.2.2 → 1.3.0

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.
@@ -2,6 +2,7 @@
2
2
  require 'nkf'
3
3
  require 'time'
4
4
  require 'net/smtp'
5
+ require 'resolv'
5
6
 
6
7
  # mailheaders
7
8
  # {
@@ -245,5 +246,16 @@ module Sendmail
245
246
  send(text, params, host)
246
247
  }
247
248
  end
249
+
250
+ #
251
+ # check validity of email address with DNS lookup.
252
+ #
253
+ def verify_address(email)
254
+ (local,domain) = parse_addrspec(email)
255
+ return false unless domain
256
+ mx = Resolv::DNS.new.getresource(domain, Resolv::DNS::Resource::IN::MX) rescue nil
257
+ return false unless mx
258
+ true
259
+ end
248
260
  end
249
261
  end
@@ -1,3 +1,3 @@
1
1
  module Egalite
2
- VERSION = "1.2.2"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -178,5 +178,9 @@ EOS
178
178
  Sendmail.send("Hello",:from => "arai@example.com", :to => "to@example.com")
179
179
  assert_match "DKIM-Signature:", Sendmail.lastmail[0]
180
180
  end
181
+ def test_verify_address
182
+ assert Sendmail.verify_address("test@gmail.com")
183
+ assert_equal false, Sendmail.verify_address("test@example.com")
184
+ end
181
185
  end
182
186
 
metadata CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
- - 2
9
- - 2
10
- version: 1.2.2
8
+ - 3
9
+ - 0
10
+ version: 1.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Shunichi Arai
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2014-05-14 00:00:00 Z
18
+ date: 2014-05-28 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: bundler