smtp_auth 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/smtp_auth.rb +25 -0
  3. metadata +45 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f36435e360f8ede48bef269a983b76418b609db9
4
+ data.tar.gz: 24bd6c971ae677d633368bf14364140de1a8f4af
5
+ SHA512:
6
+ metadata.gz: 77c0c2cc9e61125dc3fd8c23733ccb5f70bac4ea334e15efb956d4af61fb3b9042643c4a929789ea5176557305be5c033063ceaa2030c9c4ec4d31e01471a7a1
7
+ data.tar.gz: 4f8c735bbf10bbacb772a7317cd00165028cba10743be8f33fa7db96181af9a3be0d04d46395f25bd66fb5b8cf7a508f9b78638a54b8189fd342f2bf0c81fadc
data/lib/smtp_auth.rb ADDED
@@ -0,0 +1,25 @@
1
+ require 'net/smtp'
2
+ module SMTPAuth
3
+ class << self
4
+ attr_accessor :smtp
5
+ attr_accessor :logger
6
+
7
+ def config(&block)
8
+ block.call(self) if block_given?
9
+ end
10
+
11
+ def logger
12
+ @logger ||= Logger.new(STDOUT)
13
+ end
14
+
15
+ def auth(user_name, password, &block)
16
+ net_smtp = Net::SMTP.new smtp['smtp'], smtp['port']
17
+ net_smtp.enable_starttls
18
+ net_smtp.start(smtp['domain'], user_name, password, smtp['type'] || :login) { |_smtp| block.call(true) if block_given? }
19
+ true
20
+ rescue => e
21
+ logger.error("authorize '#{user_name}' error, smtp: #{smtp.to_json}, error info: #{e}")
22
+ block_given? ? block.call(false) : false
23
+ end
24
+ end
25
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: smtp_auth
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - watsy0007
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-04-20 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: auth smtp user
14
+ email: watsy0007@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/smtp_auth.rb
20
+ homepage: http://github.com/watsy0007/smtp_auth
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.5.2
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: smtp auth
44
+ test_files: []
45
+ has_rdoc: