easyemail 0.1.1 → 1.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a9a220b8980346e9ac6c59b62eaa2f42601ed821
4
- data.tar.gz: eb8dbd1b9c262a456aa14b7c3c60a803333269d0
3
+ metadata.gz: b10f81c63f44b730a19d14012eefcf33a5be5f30
4
+ data.tar.gz: 9c92103e44b05b8dfb15a4d18fd6a4b674006dcd
5
5
  SHA512:
6
- metadata.gz: 378e054803df07e7973fc8d31f2b947ca88a5a8ed3e86d742f1af54d1f66f04d00cb32367847da1b0e51d56c84c39c231037425176b9b89acaa3763232609cf3
7
- data.tar.gz: ea630d6f6647bd74486942902e63bd971a73e8c4cf12dd8efcd6c4871fe0358b08ae6b128eb8fa63fbada6cb1a09b131f82e80be6e2c8ddf8d4aa51ea1aeb46e
6
+ metadata.gz: 021a5620a544b7819a7c957a5e0e73ee6d7838726d053411075b20e8840bb7cae9c92ad43b0a1116d26f9911562e081ff46187e7b4fad0e94763c42f3e87e257
7
+ data.tar.gz: 2e2884e512faf479df5421a0e76ddebf07b7834fa061cf9cd08257327665b97c43479175cf519acccb48c94275c39cfdce33ff6e95be1ef2fc6308db05d6d76d
@@ -1,25 +1,24 @@
1
1
  require "easyemail/version"
2
+ require "mailer"
2
3
 
3
4
  class Easyemail
4
- require 'active_support'
5
- require 'action_mailer'
6
5
  require "yaml"
7
6
 
8
- ActionMailer::Base.raise_delivery_errors = true
9
- ActionMailer::Base.perform_deliveries = true
10
- ActionMailer::Base.delivery_method = :smtp
11
- ActionMailer::Base.view_paths = File.dirname(__FILE__)
7
+ attr_accessor :to
12
8
 
13
- class Mailer < ActionMailer::Base
14
- def send_email from, to, subject, content
15
- @content = content
16
- mail(
17
- to: to,
18
- from: from,
19
- subject: subject
20
- ) do | format |
21
- format.html
22
- end
9
+ @@config = YAML.load_file(File.dirname(__FILE__) + "/easyemail/smtp.yml")
10
+
11
+ @@config.each do | key, value|
12
+ define_method "smtp_settings_for_#{key}" do | p1, p2|
13
+ smtp = {
14
+ "address" => value["address"],
15
+ "port" => value["port"],
16
+ "authentication" => value["authentication"],
17
+ "user_name" => p1,
18
+ "password" => p2,
19
+ "enable_starttls_auto" => value["enable_starttls_auto"]
20
+ }
21
+ self.smtp_settings smtp
23
22
  end
24
23
  end
25
24
 
@@ -52,14 +51,8 @@ class Easyemail
52
51
  end
53
52
  end
54
53
 
55
- def to= to
56
- # 支持群发
57
- @to = to
58
- end
59
-
60
54
  def email subject, content
61
55
  # content支持html
62
-
63
56
  if @config && @to
64
57
  if @to.respond_to? :each
65
58
  @to.each do | e |
@@ -73,51 +66,11 @@ class Easyemail
73
66
  end
74
67
  end
75
68
 
76
- def smtp_settings_for_163 user_name, password
77
- smtp = {
78
- "address" => "smtp.163.com",
79
- "port" => 25,
80
- "authentication" => "login",
81
- "user_name" => user_name,
82
- "password" => password,
83
- "enable_starttls_auto" => true
84
- }
85
- self.smtp_settings smtp
86
- end
87
-
88
- def smtp_settings_for_hhu user_name, password
89
- smtp = {
90
- "address" => "mail.hhu.edu.cn",
91
- "port" => 25,
92
- "authentication" => "login",
93
- "user_name" => user_name,
94
- "password" => password,
95
- "enable_starttls_auto" => false
96
- }
97
- self.smtp_settings smtp
98
- end
99
-
100
- def smtp_settings_for_qq user_name, password
101
- smtp = {
102
- "address" => "smtp.qq.com",
103
- "port" => 25,
104
- "authentication" => "login",
105
- "user_name" => user_name,
106
- "password" => password,
107
- "enable_starttls_auto" => false
108
- }
109
- self.smtp_settings smtp
110
- end
111
-
112
- def smtp_settings_for_gmail user_name, password
113
- smtp = {
114
- "address" => "smtp.gmail.com",
115
- "port" => 587,
116
- "authentication" => "login",
117
- "user_name" => user_name,
118
- "password" => password,
119
- "enable_starttls_auto" => true
120
- }
121
- self.smtp_settings smtp
69
+ def support
70
+ ret = []
71
+ @@config.each do | key, value |
72
+ ret.push key
73
+ end
74
+ ret
122
75
  end
123
76
  end
@@ -0,0 +1,21 @@
1
+ ---
2
+ "163":
3
+ address: "smtp.163.com"
4
+ port: 25
5
+ authentication: "login"
6
+ enable_starttls_auto: true
7
+ "qq":
8
+ address: "smtp.qq.com"
9
+ port: 25
10
+ authentication: "login"
11
+ enable_starttls_auto: false
12
+ "hhu":
13
+ address: "mail.hhu.edu.cn"
14
+ port: 25
15
+ authentication: "login"
16
+ enable_starttls_auto: false
17
+ "gmail":
18
+ address: "smtp.gmail.com"
19
+ port: 587
20
+ authentication: "login"
21
+ enable_starttls_auto: true
@@ -1,3 +1,3 @@
1
1
  class Easyemail
2
- VERSION = "0.1.1"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -0,0 +1,22 @@
1
+ class Easyemail
2
+ require 'active_support'
3
+ require 'action_mailer'
4
+
5
+ ActionMailer::Base.raise_delivery_errors = true
6
+ ActionMailer::Base.perform_deliveries = true
7
+ ActionMailer::Base.delivery_method = :smtp
8
+ ActionMailer::Base.view_paths = File.dirname(__FILE__)
9
+
10
+ class Mailer < ActionMailer::Base
11
+ def send_email from, to, subject, content
12
+ @content = content
13
+ mail(
14
+ to: to,
15
+ from: from,
16
+ subject: subject
17
+ ) do | format |
18
+ format.html
19
+ end
20
+ end
21
+ end
22
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easyemail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - TUITU
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-18 00:00:00.000000000 Z
11
+ date: 2017-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -91,13 +91,13 @@ files:
91
91
  - LICENSE.txt
92
92
  - README.md
93
93
  - Rakefile
94
- - bin/console
95
- - bin/setup
96
94
  - easyemail.gemspec
97
95
  - lib/easyemail.rb
98
96
  - lib/easyemail/mailer/send_email.html.erb
99
97
  - lib/easyemail/mailer/send_email.text.erb
98
+ - lib/easyemail/smtp.yml
100
99
  - lib/easyemail/version.rb
100
+ - lib/mailer.rb
101
101
  homepage: https://github.com/hellotuitu/easyemail.
102
102
  licenses:
103
103
  - MIT
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "easyemail"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here