easyemail 0.1.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/easyemail.rb +21 -68
- data/lib/easyemail/smtp.yml +21 -0
- data/lib/easyemail/version.rb +1 -1
- data/lib/mailer.rb +22 -0
- metadata +4 -4
- data/bin/console +0 -14
- data/bin/setup +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b10f81c63f44b730a19d14012eefcf33a5be5f30
|
4
|
+
data.tar.gz: 9c92103e44b05b8dfb15a4d18fd6a4b674006dcd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 021a5620a544b7819a7c957a5e0e73ee6d7838726d053411075b20e8840bb7cae9c92ad43b0a1116d26f9911562e081ff46187e7b4fad0e94763c42f3e87e257
|
7
|
+
data.tar.gz: 2e2884e512faf479df5421a0e76ddebf07b7834fa061cf9cd08257327665b97c43479175cf519acccb48c94275c39cfdce33ff6e95be1ef2fc6308db05d6d76d
|
data/lib/easyemail.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
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
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
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
|
data/lib/easyemail/version.rb
CHANGED
data/lib/mailer.rb
ADDED
@@ -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.
|
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-
|
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
|
data/bin/console
DELETED
@@ -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
|