send 0.0.1

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/bin/send +100 -0
  3. metadata +59 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b9101a3b191750a71e4f1cd319b8e6bad57feaae
4
+ data.tar.gz: cbf2a74084c94718cfd06d903789ad27cb203cfd
5
+ SHA512:
6
+ metadata.gz: 71f47464390a7cb188738b2d01d215ead2ce5b0a2e702330896685d7decf7815d981fa519f522097f12819e581c6d0be367d2cde27f04d41e458ab1cb3a61387
7
+ data.tar.gz: 04cfc9f5ddbdd13ce507557fa2cb95f902961f6e98957a009dacf9c3e25ca3a28f0129292cb36d19ebecc3de5db70e7adec63872901947050bafcc7c0686ee5b
@@ -0,0 +1,100 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require 'mail'
4
+ require 'optparse'
5
+ require 'ostruct'
6
+
7
+ # Send mail via Command line
8
+ # This will save your defaults as environment variables so that you do
9
+ # not have to constantly add them
10
+ # I mainly use this for testing email on different browsers
11
+
12
+
13
+ options = OpenStruct.new
14
+ ran = rand(1000)
15
+ options.subject = "This is a test email - #{ran}"
16
+
17
+ # Get following defaults from environment variables
18
+ # You can set them with EXPORT
19
+ options.from = ENV['send_from']
20
+ options.to = ENV['send_to']
21
+ options.password = ENV['send_password']
22
+
23
+ opt_parser = OptionParser.new do |opt|
24
+ opt.banner = "Usage: send FILE TO"
25
+ opt.separator ""
26
+ opt.separator "Options"
27
+
28
+ opt.on("-x","--export","Export Environment Virables") do
29
+ puts "What is your gmail email? "
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
35
+ exit 0
36
+ end
37
+
38
+ opt.on("-f","--from","Your email address") do |from|
39
+ options.from = from
40
+ end
41
+
42
+ opt.on("-s","--subject","Email Subject") do |subject|
43
+ options.subject = subject
44
+ end
45
+
46
+ opt.on("-t","--to","Email address to send to") do |to|
47
+ options.from = from
48
+ end
49
+
50
+ opt.on("-h","--help","help") do
51
+ puts opt_parser
52
+ exit 0
53
+ end
54
+ end
55
+
56
+ opt_parser.parse!
57
+
58
+
59
+ file = ARGV[0]
60
+ begin
61
+ body = File.read(file)
62
+ rescue
63
+ puts "Error: File Could Not be Loaded"
64
+ exit 1
65
+ end
66
+ if ARGV[1] != nil
67
+ options.to = ARGV[1]
68
+ end
69
+
70
+ # Lets see if environment variable are set
71
+ if options.from == nil || options.to == nil || options.password == nil
72
+ puts "Envronment Variables are not set. Please run send -x to set them"
73
+ exit 1
74
+ end
75
+
76
+ Mail.defaults do
77
+ delivery_method :smtp, {
78
+ :address => 'smtp.gmail.com',
79
+ :port => '587',
80
+ :user_name => options.from,
81
+ :password => options.password,
82
+ :authentication => :plain,
83
+ :enable_starttls_auto => true
84
+ }
85
+ end
86
+
87
+ mail = Mail.new do
88
+ from options.from
89
+ to options.to
90
+ subject options.subject
91
+ end
92
+
93
+
94
+ html_part = Mail::Part.new do
95
+ content_type 'text/html; charset=UTF-8'
96
+ body body
97
+ end
98
+ mail.html_part = html_part
99
+
100
+ mail.deliver!
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: send
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Michael Revell
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ 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'
27
+ description: Send mail via cli
28
+ email: mikearevell@gmail.com
29
+ executables:
30
+ - send
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - bin/send
35
+ homepage: https://github.com/MichaelRevell/send
36
+ licenses:
37
+ - MIT
38
+ metadata: {}
39
+ post_install_message:
40
+ rdoc_options: []
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ requirements: []
54
+ rubyforge_project:
55
+ rubygems_version: 2.0.3
56
+ signing_key:
57
+ specification_version: 4
58
+ summary: Send
59
+ test_files: []