gmail_sender 1.1.1 → 1.1.2
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 +7 -0
- data/README.md +95 -0
- data/Rakefile +0 -46
- data/gmail_sender.gemspec +6 -7
- data/lib/gmail_sender.rb +1 -1
- data/test/gmail_sender_test.rb +3 -3
- data/test/test_helper.rb +2 -1
- metadata +49 -60
- data/README.rdoc +0 -64
- data/VERSION +0 -1
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6b72092b0a00558161baa22ccbc14bed1bb2ef5f
|
4
|
+
data.tar.gz: e6e15bf7c7e2bb345238f266da3ea66175174a77
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a23c9372836e8679e06e8979e936531435deb647e24b4d51e8588d2b03548c58ad62a234fe0d389a0bd11b708e5e337e976b035026748354b344bb8879a0aa0c
|
7
|
+
data.tar.gz: 19e2a4c3f86369cfea51e4478178c070a7baea28d9e0ff45de2fd8d2ca325b4dbb4a4363c9b42104b08b9930e70bba901e8c7d1f2704f6f0fe8db6460c215b7e
|
data/README.md
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
[](http://travis-ci.org/dcadenas/gmail_sender)
|
2
|
+
[](https://codeclimate.com/github/dcadenas/gmail_sender)
|
3
|
+
[](http://coderwall.com/dcadenas)
|
4
|
+
|
5
|
+
gmail_sender
|
6
|
+
============
|
7
|
+
|
8
|
+
A simple gem to send email through gmail
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
require 'gmail_sender'
|
12
|
+
|
13
|
+
g = GmailSender.new("gmail_account_user_name", "gmail_account_password")
|
14
|
+
# you can attach any number of files, but there are limits for total attachments size
|
15
|
+
g.attach('/path/to/document.hz')
|
16
|
+
g.send(:to => "someone@domain.com",
|
17
|
+
:subject => "The subject",
|
18
|
+
:content => "The mail body")
|
19
|
+
```
|
20
|
+
|
21
|
+
Notice that the `:to` key accepts an email array so you can send the message to many receivers.
|
22
|
+
You can specify the content type which is `text/plain` by default.
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
g.send(:to => "someone@domain.com",
|
26
|
+
:subject => "The subject",
|
27
|
+
:content => "<img src='http://upload.wikimedia.org/wikipedia/en/0/0d/Simpsons_FamilyPicture.png'/>",
|
28
|
+
:content_type => 'text/html')
|
29
|
+
```
|
30
|
+
|
31
|
+
To use your google apps domain instead of gmail.com include the complete sender email instead of just the user name:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
g = GmailSender.new("gmail_account_user_name@yourdomain.com", "gmail_account_password")
|
35
|
+
```
|
36
|
+
|
37
|
+
Command line usage
|
38
|
+
------------------
|
39
|
+
|
40
|
+
You can also use gmail_sender from the command line. First you need to create `~/.gmail` with this content (YAML):
|
41
|
+
|
42
|
+
```yaml
|
43
|
+
receiver_email: default_receiver@gmail.com
|
44
|
+
sender_user: gmail_account_user_name
|
45
|
+
sender_password: gmail_account_password
|
46
|
+
```
|
47
|
+
|
48
|
+
Is advisable to use a different sender account than your main email address so that it's not so bad if someone reads your configuration file and gets your password.
|
49
|
+
|
50
|
+
### Examples
|
51
|
+
|
52
|
+
To send your directory list to the default receiver:
|
53
|
+
|
54
|
+
```bash
|
55
|
+
ls | gmail
|
56
|
+
```
|
57
|
+
|
58
|
+
You can specify some parameters like in this example which doesn't use pipes:
|
59
|
+
|
60
|
+
```bash
|
61
|
+
gmail -t hansel@gmail.com gretel@hotmail.com -s "the subject" -c "the content"
|
62
|
+
```
|
63
|
+
|
64
|
+
You can send attachments by using the -a option (this example assumes that you have a receiver_email set in the `~/.gmail` file so the `-t` is not needed):
|
65
|
+
|
66
|
+
```bash
|
67
|
+
gmail -c "the attachments" -a ./VERSION ./gmail_sender.gemspec
|
68
|
+
```
|
69
|
+
|
70
|
+
To send html content use the ct option
|
71
|
+
|
72
|
+
```bash
|
73
|
+
gmail -c "<img src='http://host/image.png'/>" -ct text/html
|
74
|
+
```
|
75
|
+
|
76
|
+
Installation
|
77
|
+
------------
|
78
|
+
|
79
|
+
```bash
|
80
|
+
gem install gmail_sender
|
81
|
+
```
|
82
|
+
|
83
|
+
Requirements
|
84
|
+
------------
|
85
|
+
|
86
|
+
tlsmail if running Ruby 1.8.6
|
87
|
+
|
88
|
+
Major contributors
|
89
|
+
------------------
|
90
|
+
|
91
|
+
* Daniel Cadenas - Maintainer
|
92
|
+
* Felipe Coury
|
93
|
+
* iwakura
|
94
|
+
* saks
|
95
|
+
* elcuervo
|
data/Rakefile
CHANGED
@@ -1,23 +1,6 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rake'
|
3
3
|
|
4
|
-
begin
|
5
|
-
require 'jeweler'
|
6
|
-
Jeweler::Tasks.new do |gem|
|
7
|
-
gem.name = "gmail_sender"
|
8
|
-
gem.summary = %Q{A simple gem to send email through gmail}
|
9
|
-
gem.email = "dcadenas@gmail.com"
|
10
|
-
gem.homepage = "http://github.com/dcadenas/gmail_sender"
|
11
|
-
gem.authors = ["Daniel Cadenas"]
|
12
|
-
gem.add_development_dependency "expectations"
|
13
|
-
gem.add_development_dependency "filetesthelper"
|
14
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
|
-
end
|
16
|
-
|
17
|
-
rescue LoadError
|
18
|
-
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
19
|
-
end
|
20
|
-
|
21
4
|
require 'rake/testtask'
|
22
5
|
Rake::TestTask.new(:test) do |test|
|
23
6
|
test.libs << 'lib' << 'test'
|
@@ -25,34 +8,5 @@ Rake::TestTask.new(:test) do |test|
|
|
25
8
|
test.verbose = true
|
26
9
|
end
|
27
10
|
|
28
|
-
begin
|
29
|
-
require 'rcov/rcovtask'
|
30
|
-
Rcov::RcovTask.new do |test|
|
31
|
-
test.libs << 'test'
|
32
|
-
test.pattern = 'test/**/*_test.rb'
|
33
|
-
test.verbose = true
|
34
|
-
end
|
35
|
-
rescue LoadError
|
36
|
-
task :rcov do
|
37
|
-
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
|
42
11
|
task :default => :test
|
43
12
|
|
44
|
-
require 'rake/rdoctask'
|
45
|
-
Rake::RDocTask.new do |rdoc|
|
46
|
-
if File.exist?('VERSION.yml')
|
47
|
-
config = YAML.load(File.read('VERSION.yml'))
|
48
|
-
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
49
|
-
else
|
50
|
-
version = ""
|
51
|
-
end
|
52
|
-
|
53
|
-
rdoc.rdoc_dir = 'rdoc'
|
54
|
-
rdoc.title = "gmail_sender #{version}"
|
55
|
-
rdoc.rdoc_files.include('README*')
|
56
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
57
|
-
end
|
58
|
-
|
data/gmail_sender.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{gmail_sender}
|
8
|
-
s.version = "1.1.
|
8
|
+
s.version = "1.1.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Daniel Cadenas"]
|
@@ -15,15 +15,14 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.executables = ["gmail"]
|
16
16
|
s.extra_rdoc_files = [
|
17
17
|
"LICENSE",
|
18
|
-
"README.
|
18
|
+
"README.md"
|
19
19
|
]
|
20
20
|
s.files = [
|
21
21
|
".document",
|
22
22
|
".gitignore",
|
23
23
|
"LICENSE",
|
24
|
-
"README.
|
24
|
+
"README.md",
|
25
25
|
"Rakefile",
|
26
|
-
"VERSION",
|
27
26
|
"bin/gmail",
|
28
27
|
"gmail_sender.gemspec",
|
29
28
|
"lib/gmail_sender.rb",
|
@@ -52,14 +51,14 @@ Gem::Specification.new do |s|
|
|
52
51
|
|
53
52
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
54
53
|
s.add_development_dependency(%q<expectations>, [">= 0"])
|
55
|
-
s.add_development_dependency(%q<
|
54
|
+
s.add_development_dependency(%q<file_test_helper>, [">= 0"])
|
56
55
|
else
|
57
56
|
s.add_dependency(%q<expectations>, [">= 0"])
|
58
|
-
s.add_dependency(%q<
|
57
|
+
s.add_dependency(%q<file_test_helper>, [">= 0"])
|
59
58
|
end
|
60
59
|
else
|
61
60
|
s.add_dependency(%q<expectations>, [">= 0"])
|
62
|
-
s.add_dependency(%q<
|
61
|
+
s.add_dependency(%q<file_test_helper>, [">= 0"])
|
63
62
|
end
|
64
63
|
end
|
65
64
|
|
data/lib/gmail_sender.rb
CHANGED
@@ -26,7 +26,7 @@ class GmailSender
|
|
26
26
|
to = [options[:to]].flatten
|
27
27
|
subject = options[:subject] || ""
|
28
28
|
content = options[:content] || ""
|
29
|
-
content_type = options[:content_type] ||
|
29
|
+
content_type = options[:content_type] || 'text/plain; charset=UTF-8'
|
30
30
|
|
31
31
|
@net_smtp.start(@sender_domain, @sender_email, @sender_password, :plain) do |smtp|
|
32
32
|
smtp.open_message_stream(@sender_email, to) do |msg_stream|
|
data/test/gmail_sender_test.rb
CHANGED
@@ -23,19 +23,19 @@ class FakedNetSMTP
|
|
23
23
|
end
|
24
24
|
|
25
25
|
Expectations do
|
26
|
-
expect "From: me@gmail.com\nTo: someone@somehost.com\nSubject: hi!\nMIME-Version: 1.0\nContent-Type: text/plain; charset=
|
26
|
+
expect "From: me@gmail.com\nTo: someone@somehost.com\nSubject: hi!\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\n\nho\n" do
|
27
27
|
gmail_sender = GmailSender.new("me", "password", FakedNetSMTP)
|
28
28
|
gmail_sender.send(:to => "someone@somehost.com", :subject => "hi!", :content => "ho")
|
29
29
|
FakedNetSMTP.sent_email
|
30
30
|
end
|
31
31
|
|
32
|
-
expect "From: me@somehost.com\nTo: someone@someotherhost.com\nSubject: hi!\nMIME-Version: 1.0\nContent-Type: text/plain; charset=
|
32
|
+
expect "From: me@somehost.com\nTo: someone@someotherhost.com\nSubject: hi!\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\n\nho\n" do
|
33
33
|
gmail_sender = GmailSender.new("me@somehost.com", "password", FakedNetSMTP)
|
34
34
|
gmail_sender.send(:to => "someone@someotherhost.com", :subject => "hi!", :content => "ho")
|
35
35
|
FakedNetSMTP.sent_email
|
36
36
|
end
|
37
37
|
|
38
|
-
expect "From: me@somehost.com\nTo: someone@someotherhost.com,someone2@someotherhost.com\nSubject: hi!\nMIME-Version: 1.0\nContent-Type: text/plain; charset=
|
38
|
+
expect "From: me@somehost.com\nTo: someone@someotherhost.com,someone2@someotherhost.com\nSubject: hi!\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\n\nho\n" do
|
39
39
|
gmail_sender = GmailSender.new("me@somehost.com", "password", FakedNetSMTP)
|
40
40
|
gmail_sender.send(:to => ["someone@someotherhost.com", "someone2@someotherhost.com"], :subject => "hi!", :content => "ho")
|
41
41
|
FakedNetSMTP.sent_email
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,62 +1,57 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: gmail_sender
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
segments:
|
6
|
-
- 1
|
7
|
-
- 1
|
8
|
-
- 1
|
9
|
-
version: 1.1.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.2
|
10
5
|
platform: ruby
|
11
|
-
authors:
|
6
|
+
authors:
|
12
7
|
- Daniel Cadenas
|
13
8
|
autorequire:
|
14
9
|
bindir: bin
|
15
10
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2010-06-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
21
14
|
name: expectations
|
22
|
-
|
23
|
-
|
24
|
-
requirements:
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
25
17
|
- - ">="
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
|
28
|
-
- 0
|
29
|
-
version: "0"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
30
20
|
type: :development
|
31
|
-
version_requirements: *id001
|
32
|
-
- !ruby/object:Gem::Dependency
|
33
|
-
name: filetesthelper
|
34
21
|
prerelease: false
|
35
|
-
|
36
|
-
requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: file_test_helper
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
37
31
|
- - ">="
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
|
40
|
-
- 0
|
41
|
-
version: "0"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
42
34
|
type: :development
|
43
|
-
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
44
41
|
description:
|
45
42
|
email: dcadenas@gmail.com
|
46
|
-
executables:
|
43
|
+
executables:
|
47
44
|
- gmail
|
48
45
|
extensions: []
|
49
|
-
|
50
|
-
extra_rdoc_files:
|
46
|
+
extra_rdoc_files:
|
51
47
|
- LICENSE
|
52
|
-
- README.
|
53
|
-
files:
|
54
|
-
- .document
|
55
|
-
- .gitignore
|
48
|
+
- README.md
|
49
|
+
files:
|
50
|
+
- ".document"
|
51
|
+
- ".gitignore"
|
56
52
|
- LICENSE
|
57
|
-
- README.
|
53
|
+
- README.md
|
58
54
|
- Rakefile
|
59
|
-
- VERSION
|
60
55
|
- bin/gmail
|
61
56
|
- gmail_sender.gemspec
|
62
57
|
- lib/gmail_sender.rb
|
@@ -67,37 +62,31 @@ files:
|
|
67
62
|
- test/gmail_sender_test.rb
|
68
63
|
- test/message_stream_writer_test.rb
|
69
64
|
- test/test_helper.rb
|
70
|
-
has_rdoc: true
|
71
65
|
homepage: http://github.com/dcadenas/gmail_sender
|
72
66
|
licenses: []
|
73
|
-
|
67
|
+
metadata: {}
|
74
68
|
post_install_message:
|
75
|
-
rdoc_options:
|
76
|
-
- --charset=UTF-8
|
77
|
-
require_paths:
|
69
|
+
rdoc_options:
|
70
|
+
- "--charset=UTF-8"
|
71
|
+
require_paths:
|
78
72
|
- lib
|
79
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
-
requirements:
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
81
75
|
- - ">="
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
-
requirements:
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
88
80
|
- - ">="
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
|
91
|
-
- 0
|
92
|
-
version: "0"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
93
83
|
requirements: []
|
94
|
-
|
95
84
|
rubyforge_project:
|
96
|
-
rubygems_version:
|
85
|
+
rubygems_version: 2.2.2
|
97
86
|
signing_key:
|
98
87
|
specification_version: 3
|
99
88
|
summary: A simple gem to send email through gmail
|
100
|
-
test_files:
|
89
|
+
test_files:
|
101
90
|
- test/gmail_sender_test.rb
|
102
91
|
- test/message_stream_writer_test.rb
|
103
92
|
- test/test_helper.rb
|
data/README.rdoc
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
= gmail_sender
|
2
|
-
|
3
|
-
A simple gem to send email through gmail
|
4
|
-
|
5
|
-
require 'rubygems'
|
6
|
-
require 'gmail_sender'
|
7
|
-
|
8
|
-
g = GmailSender.new("gmail_account_user_name", "gmail_account_password")
|
9
|
-
g.attach('/path/to/document.hz') # you can attach any number of files, but there are limits for total attachments size
|
10
|
-
g.send(:to => "someone@domain.com", :subject => "The subject", :content => "The mail body")
|
11
|
-
|
12
|
-
Notice that the ':to' key accepts an email array so you can send the message to many receivers.
|
13
|
-
You can specify the content type which is text/plain by default.
|
14
|
-
|
15
|
-
g.send(:to => "someone@domain.com",
|
16
|
-
:subject => "The subject",
|
17
|
-
:content => "<img src='http://upload.wikimedia.org/wikipedia/en/0/0d/Simpsons_FamilyPicture.png'/>",
|
18
|
-
:content_type => 'text/html')
|
19
|
-
|
20
|
-
To use your google apps domain instead of gmail.com include the complete sender email instead of just the user name:
|
21
|
-
|
22
|
-
g = GmailSender.new("gmail_account_user_name@yourdomain.com", "gmail_account_password")
|
23
|
-
|
24
|
-
== Command line usage
|
25
|
-
|
26
|
-
You can also use gmail_sender from the command line. First you need to create ~/.gmail with this content (YAML):
|
27
|
-
|
28
|
-
receiver_email: default_receiver@gmail.com
|
29
|
-
sender_user: gmail_account_user_name
|
30
|
-
sender_password: gmail_account_password
|
31
|
-
|
32
|
-
Is advisable to use a different sender account than your main email address so that it's not so bad if someone reads your configuration file and gets your password.
|
33
|
-
|
34
|
-
=== Examples
|
35
|
-
|
36
|
-
To send your directory list to the default receiver:
|
37
|
-
|
38
|
-
ls | gmail
|
39
|
-
|
40
|
-
You can specify some parameters like in this example which doesn't use pipes:
|
41
|
-
|
42
|
-
gmail -t somebody@gmail.com someoneelse@hotmail.com -s "This is the subject" -c "This is the email content"
|
43
|
-
|
44
|
-
You can send attachments by using the -a option (this example assumes that you have a receiver_email set in the ~/.gmail file so the -t is not needed):
|
45
|
-
|
46
|
-
gmail -c "hi, I'm sending some attachments" -a ./VERSION ./gmail_sender.gemspec
|
47
|
-
|
48
|
-
To send html content use the ct option
|
49
|
-
|
50
|
-
gmail -c "<img src='http://upload.wikimedia.org/wikipedia/en/0/0d/Simpsons_FamilyPicture.png'/>" -ct text/html
|
51
|
-
|
52
|
-
== Installation
|
53
|
-
|
54
|
-
sudo gem install gmail_sender
|
55
|
-
|
56
|
-
== Requirements
|
57
|
-
|
58
|
-
tlsmail if running Ruby 1.8.6
|
59
|
-
|
60
|
-
== Major contributors
|
61
|
-
|
62
|
-
* Daniel Cadenas - Maintainer
|
63
|
-
* Felipe Coury
|
64
|
-
* iwakura
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.1.1
|