ruboty-sendmail 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f3e2f50de77e081b1ff9a110b4742634cd47041d
4
+ data.tar.gz: c3b3b8dcb5c9124052f7cc798fe0013bb4bac634
5
+ SHA512:
6
+ metadata.gz: 83c2062ddf023bca5c6f342c4eb76a0327543dc8bd53155a2d6049ee4bfc3a43d6d542a0d1d1c1e42c915110b76019e86e186e2c41617b8213b4fd978efc40eb
7
+ data.tar.gz: 52956dd0618e3bb7bca2a9dcaf961c9b8974086937e969e6c2dcae584dfac93ab9348cbcc0a9a8ca8d51188759b080c912fba4343684341d415cf97f38745b53
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ruboty-sendmail.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 kaihar4
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # Ruboty::Sendmail
2
+
3
+ Ruboty handler to send a mail.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'ruboty-sendmail'
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```
16
+ @ruboty sendmail <address> <body>
17
+ ```
18
+
19
+ ## Example
20
+
21
+ ```
22
+ > @ruboty sendmail foo@bar.com This is test.
23
+ Success!
24
+ ```
25
+
26
+ ## Setting
27
+
28
+ ```
29
+ # $HOME/.ruboty-sendmail.yml
30
+
31
+ method: :smtp # Default: :smtp
32
+ subject: 'ALERT!' # Default: 'Send by ruboty-sendmail'
33
+ from: 'username@foo.com' # REQUIRED
34
+
35
+ option:
36
+ address: 'mail.foo.com'
37
+ port: 465
38
+ domain: 'foo.com'
39
+ authentication: :plain
40
+ user_name: 'username'
41
+ password: 'password'
42
+ ssl: true
43
+ ```
44
+
45
+ ### Available Options
46
+
47
+ Option | Default
48
+ --- | ---
49
+ address | 'localhost'
50
+ port | 25
51
+ domain | 'localhost.localdomain'
52
+ authentication | nil
53
+ user\_name | nil
54
+ password | nil
55
+ ssl | nil
56
+ enable\_starttls\_auto | true
57
+ openssl\_verify\_mode | nil
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,52 @@
1
+ require 'yaml'
2
+
3
+ require 'mail'
4
+
5
+ module Ruboty
6
+ module Handlers
7
+ class Sendmail < Base
8
+ on /sendmail (?<address>.+) (?<body>.+)/, name: 'sendmail', description: 'Send a mail'
9
+
10
+ def sendmail(message)
11
+ mail_config = YAML.load_file("#{ENV['HOME']}/.ruboty-sendmail.yml")
12
+
13
+ mail = Mail.new do |config|
14
+ config.subject mail_config['subject'] || 'Send by ruboty-sendmail'
15
+ config.from mail_config['from']
16
+ config.to message[:address]
17
+ config.body message[:body]
18
+ end
19
+
20
+ method = mail_config['method'] || :smtp
21
+
22
+ default_option = {
23
+ address: 'localhost',
24
+ port: 25,
25
+ domain: 'localhost.localdomain',
26
+ authentication: nil,
27
+ user_name: nil,
28
+ password: nil,
29
+ ssl: nil,
30
+ enable_starttls_auto: true,
31
+ openssl_verify_mode: nil
32
+ }
33
+ option = default_option.merge(symbolize_keys(mail_config['option']))
34
+
35
+ mail.delivery_method(method, option)
36
+ begin
37
+ mail.deliver!
38
+ rescue
39
+ message.reply('Failed :-(')
40
+ else
41
+ message.reply('Success!')
42
+ end
43
+ end
44
+
45
+ def symbolize_keys(hash)
46
+ hash.each_with_object({}) do |(k, v), retval|
47
+ retval[k.to_sym] = v
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,5 @@
1
+ module Ruboty
2
+ module Sendmail
3
+ VERSION = '0.0.1'
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require 'ruboty'
2
+ require 'ruboty/handlers/sendmail'
@@ -0,0 +1,24 @@
1
+ $LOAD_PATH << File.expand_path('../lib', __FILE__)
2
+ require 'ruboty/sendmail/version'
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = 'ruboty-sendmail'
6
+ spec.version = Ruboty::Sendmail::VERSION
7
+ spec.authors = ['kaihar4']
8
+ spec.email = ['kaihar4@gmail.com']
9
+ spec.summary = 'Ruboty handler to send a mail.'
10
+ spec.description = spec.summary
11
+ spec.homepage = 'https://github.com/kaihar4/ruboty-sendmail'
12
+ spec.license = 'MIT'
13
+
14
+ spec.files = `git ls-files -z`.split("\x0")
15
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
+ spec.require_paths = ['lib']
18
+
19
+ spec.add_dependency 'ruboty'
20
+ spec.add_dependency 'mail'
21
+
22
+ spec.add_development_dependency 'bundler'
23
+ spec.add_development_dependency 'rake'
24
+ end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruboty-sendmail
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - kaihar4
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ruboty
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
+ - !ruby/object:Gem::Dependency
28
+ name: mail
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Ruboty handler to send a mail.
70
+ email:
71
+ - kaihar4@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - lib/ruboty/handlers/sendmail.rb
82
+ - lib/ruboty/sendmail.rb
83
+ - lib/ruboty/sendmail/version.rb
84
+ - ruboty-sendmail.gemspec
85
+ homepage: https://github.com/kaihar4/ruboty-sendmail
86
+ licenses:
87
+ - MIT
88
+ metadata: {}
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 2.2.2
106
+ signing_key:
107
+ specification_version: 4
108
+ summary: Ruboty handler to send a mail.
109
+ test_files: []