send 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/send +51 -24
- metadata +3 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 332584d658789e426d4b0465522d12c0a66be5fe
|
4
|
+
data.tar.gz: f4650323611b761496e26b1f033f3b6ea9097792
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1f2996c493bf0b1b1b58c9409fc195b2474137c03558e088ebd593a81ae09ce8765d4a5d3f5bd90156c1ef029c62f54687ed18195fe5fa9d173cf3835690e8f
|
7
|
+
data.tar.gz: fb0d185124fd57ae31184572b9226b1169c6189647af39d6f2b5d173861ad52aee8c2d65a9776fa189d23390a872cdb1402d33f9c8c796c56d8a982018fc62df
|
data/bin/send
CHANGED
@@ -1,24 +1,56 @@
|
|
1
|
-
#!/usr/bin/ruby
|
1
|
+
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'mail'
|
4
4
|
require 'optparse'
|
5
5
|
require 'ostruct'
|
6
|
+
require 'io/console'
|
7
|
+
require 'base64'
|
6
8
|
|
7
9
|
# Send mail via Command line
|
8
|
-
# This will save your defaults as environment variables so that you do
|
10
|
+
# This will save your defaults as environment variables so that you do
|
9
11
|
# not have to constantly add them
|
10
12
|
# I mainly use this for testing email on different browsers
|
11
13
|
|
14
|
+
OPTIONS = OpenStruct.new
|
15
|
+
CONFIG_FNAME = "#{ENV['HOME']}/.send"
|
16
|
+
|
17
|
+
def read_config
|
18
|
+
if File.file? CONFIG_FNAME
|
19
|
+
f = open(CONFIG_FNAME)
|
20
|
+
contents = Base64.decode64(f.read)
|
21
|
+
OPTIONS.from = contents.match(/^from=(.*)$/)[1]
|
22
|
+
OPTIONS.to = contents.match(/^to=(.*)$/)[1]
|
23
|
+
OPTIONS.password = contents.match(/^password=(.*)$/)[1]
|
24
|
+
f.close
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def write_config
|
29
|
+
contents = ''
|
30
|
+
contents << "from=#{OPTIONS.from}\n"
|
31
|
+
contents << "to=#{OPTIONS.to}\n"
|
32
|
+
contents << "password=#{OPTIONS.password}"
|
33
|
+
f = open(CONFIG_FNAME, 'w')
|
34
|
+
f.write(Base64.encode64(contents))
|
35
|
+
f.close
|
36
|
+
end
|
37
|
+
|
38
|
+
def export
|
39
|
+
puts "What is your gmail email? "
|
40
|
+
OPTIONS.from = gets.chomp
|
41
|
+
puts "What is your gmail password? "
|
42
|
+
OPTIONS.password = STDIN.noecho(&:gets).chomp
|
43
|
+
puts "Who should we send the email to by default? "
|
44
|
+
OPTIONS.to = gets.chomp
|
45
|
+
write_config
|
46
|
+
end
|
12
47
|
|
13
|
-
options = OpenStruct.new
|
14
48
|
ran = rand(1000)
|
15
|
-
|
49
|
+
OPTIONS.subject = "This is a test email - #{ran}"
|
16
50
|
|
17
51
|
# Get following defaults from environment variables
|
18
52
|
# You can set them with EXPORT
|
19
|
-
|
20
|
-
options.to = ENV['send_to']
|
21
|
-
options.password = ENV['send_password']
|
53
|
+
read_config
|
22
54
|
|
23
55
|
opt_parser = OptionParser.new do |opt|
|
24
56
|
opt.banner = "Usage: send FILE TO"
|
@@ -26,25 +58,20 @@ opt_parser = OptionParser.new do |opt|
|
|
26
58
|
opt.separator "Options"
|
27
59
|
|
28
60
|
opt.on("-x","--export","Export Environment Virables") do
|
29
|
-
|
30
|
-
system "export send_from=" + gets.chomp
|
31
|
-
puts "What is your gmail password? "
|
32
|
-
system "export send_password=" + gets.chomp
|
33
|
-
puts "Who should we send the email to by default? "
|
34
|
-
system "export send_to=" + gets.chomp
|
61
|
+
export
|
35
62
|
exit 0
|
36
63
|
end
|
37
64
|
|
38
65
|
opt.on("-f","--from","Your email address") do |from|
|
39
|
-
|
66
|
+
OPTIONS.from = from
|
40
67
|
end
|
41
68
|
|
42
69
|
opt.on("-s","--subject","Email Subject") do |subject|
|
43
|
-
|
70
|
+
OPTIONS.subject = subject
|
44
71
|
end
|
45
72
|
|
46
73
|
opt.on("-t","--to","Email address to send to") do |to|
|
47
|
-
|
74
|
+
OPTIONS.from = from
|
48
75
|
end
|
49
76
|
|
50
77
|
opt.on("-h","--help","help") do
|
@@ -64,30 +91,30 @@ rescue
|
|
64
91
|
exit 1
|
65
92
|
end
|
66
93
|
if ARGV[1] != nil
|
67
|
-
|
94
|
+
OPTIONS.to = ARGV[1]
|
68
95
|
end
|
69
96
|
|
70
97
|
# Lets see if environment variable are set
|
71
|
-
if
|
98
|
+
if OPTIONS.from == nil || OPTIONS.to == nil || OPTIONS.password == nil
|
72
99
|
puts "Envronment Variables are not set. Please run send -x to set them"
|
73
100
|
exit 1
|
74
101
|
end
|
75
102
|
|
76
103
|
Mail.defaults do
|
77
|
-
delivery_method :smtp, {
|
104
|
+
delivery_method :smtp, {
|
78
105
|
:address => 'smtp.gmail.com',
|
79
106
|
:port => '587',
|
80
|
-
:user_name =>
|
81
|
-
:password =>
|
107
|
+
:user_name => OPTIONS.from,
|
108
|
+
:password => OPTIONS.password,
|
82
109
|
:authentication => :plain,
|
83
110
|
:enable_starttls_auto => true
|
84
111
|
}
|
85
112
|
end
|
86
113
|
|
87
114
|
mail = Mail.new do
|
88
|
-
from
|
89
|
-
to
|
90
|
-
subject
|
115
|
+
from OPTIONS.from
|
116
|
+
to OPTIONS.to
|
117
|
+
subject OPTIONS.subject
|
91
118
|
end
|
92
119
|
|
93
120
|
|
metadata
CHANGED
@@ -1,29 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: send
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Revell
|
8
|
+
- Emanuel Evans
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
12
|
date: 2013-06-08 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: mail
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - '>='
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - '>='
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
13
|
+
dependencies: []
|
27
14
|
description: Send mail via cli
|
28
15
|
email: mikearevell@gmail.com
|
29
16
|
executables:
|