gmail-mailer 0.1.1 → 0.2.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.
- data/Gemfile +1 -1
- data/Gemfile.lock +2 -2
- data/README.rdoc +34 -0
- data/Rakefile +1 -1
- data/TODO.txt +3 -0
- data/VERSION +1 -1
- data/gmail-mailer.gemspec +8 -7
- data/lib/gmail-mailer.rb +10 -6
- metadata +9 -8
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -10,7 +10,7 @@ GEM
|
|
10
10
|
bundler (~> 1.0.0)
|
11
11
|
git (>= 1.2.5)
|
12
12
|
rake
|
13
|
-
mail (2.2.
|
13
|
+
mail (2.2.14)
|
14
14
|
activesupport (>= 2.3.6)
|
15
15
|
i18n (>= 0.4.0)
|
16
16
|
mime-types (~> 1.16)
|
@@ -29,4 +29,4 @@ DEPENDENCIES
|
|
29
29
|
bundler (~> 1.0.0)
|
30
30
|
gmail_xoauth (~> 0.3.0)
|
31
31
|
jeweler (~> 1.5.2)
|
32
|
-
mail (~> 2.2.
|
32
|
+
mail (~> 2.2.14)
|
data/README.rdoc
CHANGED
@@ -2,6 +2,40 @@
|
|
2
2
|
|
3
3
|
simple gem to allow you to send emails using your gmail account (without having to fiddle around with passwords)
|
4
4
|
|
5
|
+
= Usage
|
6
|
+
== Creating a message
|
7
|
+
message = GmailMailer::Message.new("to", "from", "Hello Subject", "Hello Body")
|
8
|
+
|
9
|
+
== Adding attachments
|
10
|
+
((*NOTE:*))Only single attachments work at the current moment in time
|
11
|
+
message.add_attachment(Filepath)
|
12
|
+
|
13
|
+
== Setting up gmail-mailer
|
14
|
+
You will need to provide mailer with a hashmap containing the ouath details for your account.
|
15
|
+
|
16
|
+
== Sending a message
|
17
|
+
mailer.send(message)
|
18
|
+
|
19
|
+
== Example application
|
20
|
+
require 'gmail-mailer'
|
21
|
+
email_credentials =
|
22
|
+
{
|
23
|
+
:smtp_server=>"smtp.gmail.com",
|
24
|
+
:smtp_port=>587,
|
25
|
+
:smtp_consumer_key=>"anonymous",
|
26
|
+
:smtp_consumer_secret=>"anonymous",
|
27
|
+
:smtp_oauth_token=>"<your outh_token>",
|
28
|
+
:smtp_oauth_token_secret=>"<your ouath token secret>",
|
29
|
+
:host=>"gmail.com",
|
30
|
+
:email=>"<your gmail address>"
|
31
|
+
}
|
32
|
+
|
33
|
+
message = GmailMailer::Message.new("to","from", "Hello Subject", "Hello Body")
|
34
|
+
message.add_attachment(File.expand_path('~/image.png'))
|
35
|
+
|
36
|
+
mailer = GmailMailer::Mailer.new(email_credentials)
|
37
|
+
mailer.send(message)
|
38
|
+
|
5
39
|
== Contributing to gmail-mailer
|
6
40
|
|
7
41
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
data/Rakefile
CHANGED
@@ -19,7 +19,7 @@ Jeweler::Tasks.new do |gem|
|
|
19
19
|
gem.description = %Q{Programatically send emails using a given gmail account. No username/passwords needed, just use your OAUTH credentials}
|
20
20
|
gem.email = "djharperuk@gmail.com"
|
21
21
|
gem.authors = ["Daniel Harper"]
|
22
|
-
gem.add_dependency "mail","~> 2.2.
|
22
|
+
gem.add_dependency "mail","~> 2.2.14"
|
23
23
|
gem.add_dependency "gmail_xoauth", "~> 0.3.0"
|
24
24
|
end
|
25
25
|
Jeweler::RubygemsDotOrgTasks.new
|
data/TODO.txt
ADDED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/gmail-mailer.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{gmail-mailer}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Daniel Harper"]
|
@@ -23,6 +23,7 @@ Gem::Specification.new do |s|
|
|
23
23
|
"LICENSE.txt",
|
24
24
|
"README.rdoc",
|
25
25
|
"Rakefile",
|
26
|
+
"TODO.txt",
|
26
27
|
"VERSION",
|
27
28
|
"gmail-mailer.gemspec",
|
28
29
|
"lib/gmail-mailer.rb"
|
@@ -40,24 +41,24 @@ Gem::Specification.new do |s|
|
|
40
41
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
41
42
|
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
42
43
|
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
43
|
-
s.add_development_dependency(%q<mail>, ["~> 2.2.
|
44
|
+
s.add_development_dependency(%q<mail>, ["~> 2.2.14"])
|
44
45
|
s.add_development_dependency(%q<gmail_xoauth>, ["~> 0.3.0"])
|
45
|
-
s.add_runtime_dependency(%q<mail>, ["~> 2.2.
|
46
|
+
s.add_runtime_dependency(%q<mail>, ["~> 2.2.14"])
|
46
47
|
s.add_runtime_dependency(%q<gmail_xoauth>, ["~> 0.3.0"])
|
47
48
|
else
|
48
49
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
49
50
|
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
50
|
-
s.add_dependency(%q<mail>, ["~> 2.2.
|
51
|
+
s.add_dependency(%q<mail>, ["~> 2.2.14"])
|
51
52
|
s.add_dependency(%q<gmail_xoauth>, ["~> 0.3.0"])
|
52
|
-
s.add_dependency(%q<mail>, ["~> 2.2.
|
53
|
+
s.add_dependency(%q<mail>, ["~> 2.2.14"])
|
53
54
|
s.add_dependency(%q<gmail_xoauth>, ["~> 0.3.0"])
|
54
55
|
end
|
55
56
|
else
|
56
57
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
57
58
|
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
58
|
-
s.add_dependency(%q<mail>, ["~> 2.2.
|
59
|
+
s.add_dependency(%q<mail>, ["~> 2.2.14"])
|
59
60
|
s.add_dependency(%q<gmail_xoauth>, ["~> 0.3.0"])
|
60
|
-
s.add_dependency(%q<mail>, ["~> 2.2.
|
61
|
+
s.add_dependency(%q<mail>, ["~> 2.2.14"])
|
61
62
|
s.add_dependency(%q<gmail_xoauth>, ["~> 0.3.0"])
|
62
63
|
end
|
63
64
|
end
|
data/lib/gmail-mailer.rb
CHANGED
@@ -7,14 +7,14 @@ module GmailMailer
|
|
7
7
|
@email_credentials = credentials
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
10
|
+
def send(message)
|
11
11
|
mail = Mail.new do
|
12
12
|
from message.from
|
13
13
|
to message.to
|
14
14
|
subject message.subject
|
15
15
|
body message.body
|
16
|
-
if(message.
|
17
|
-
add_file message.
|
16
|
+
if(!message.attachments.empty?)
|
17
|
+
add_file message.attachments.first
|
18
18
|
end
|
19
19
|
end
|
20
20
|
sendSMTP(mail)
|
@@ -52,13 +52,17 @@ module GmailMailer
|
|
52
52
|
end
|
53
53
|
|
54
54
|
class Message
|
55
|
-
attr_reader :to, :from, :subject, :body, :
|
56
|
-
def initialize(to, from,
|
55
|
+
attr_reader :to, :from, :subject, :body, :attachments
|
56
|
+
def initialize(to, from, subject="", body="")
|
57
57
|
@to = to
|
58
58
|
@from = from
|
59
59
|
@subject = subject
|
60
60
|
@body = body
|
61
|
-
@
|
61
|
+
@attachments = []
|
62
|
+
end
|
63
|
+
|
64
|
+
def add_attachment(filepath)
|
65
|
+
@attachments << filepath if !filepath.nil? or !filepath.empty?
|
62
66
|
end
|
63
67
|
end
|
64
68
|
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 0.2.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Daniel Harper
|
@@ -57,8 +57,8 @@ dependencies:
|
|
57
57
|
segments:
|
58
58
|
- 2
|
59
59
|
- 2
|
60
|
-
-
|
61
|
-
version: 2.2.
|
60
|
+
- 14
|
61
|
+
version: 2.2.14
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: *id003
|
@@ -87,8 +87,8 @@ dependencies:
|
|
87
87
|
segments:
|
88
88
|
- 2
|
89
89
|
- 2
|
90
|
-
-
|
91
|
-
version: 2.2.
|
90
|
+
- 14
|
91
|
+
version: 2.2.14
|
92
92
|
type: :runtime
|
93
93
|
prerelease: false
|
94
94
|
version_requirements: *id005
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- LICENSE.txt
|
124
124
|
- README.rdoc
|
125
125
|
- Rakefile
|
126
|
+
- TODO.txt
|
126
127
|
- VERSION
|
127
128
|
- gmail-mailer.gemspec
|
128
129
|
- lib/gmail-mailer.rb
|
@@ -140,7 +141,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
140
141
|
requirements:
|
141
142
|
- - ">="
|
142
143
|
- !ruby/object:Gem::Version
|
143
|
-
hash: -
|
144
|
+
hash: -2151435929044116729
|
144
145
|
segments:
|
145
146
|
- 0
|
146
147
|
version: "0"
|