logstash-output-email-v2 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +55 -0
- data/CONTRIBUTORS +23 -0
- data/Gemfile +11 -0
- data/LICENSE +202 -0
- data/NOTICE.TXT +5 -0
- data/README.md +104 -0
- data/docs/index.asciidoc +259 -0
- data/lib/logstash/outputs/email.rb +194 -0
- data/logstash-output-email.gemspec +37 -0
- data/spec/fixtures/template.mustache +1 -0
- data/spec/outputs/email_spec.rb +125 -0
- data/spec/spec_helper.rb +28 -0
- metadata +180 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1d9e648f5a2305ce3f73464845b9dbe00dc8c2b1a38e8f9dcfcf8cac4d0c13a0
|
4
|
+
data.tar.gz: 88cf580b5fddb213b7c06cc1477e9efa6bbfb3c34a34de4a43ab0bc1ab9af2ab
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d4abc8867b2854f30efc6effa5e9f68c532b68c4b1e8a68495f6bec06da607def97dc1ed1f5964ace8e9ea5f28300075c4847adac26dcaf6ca5bb956ac24e02d
|
7
|
+
data.tar.gz: a8340ecf12bd2fc4409388ecb07c683c1bff755156024cc92d10ca11699300d346d65738e6e009cac0c33f83d48c614d8f9825141b99a3456ce47c3798bcd7b8
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
## 4.1.1
|
2
|
+
- Docs: Set the default_codec doc attribute.
|
3
|
+
|
4
|
+
## 4.1.0
|
5
|
+
- Update gemspec summary
|
6
|
+
- Add bcc suport #55
|
7
|
+
- Add mustache templating #51
|
8
|
+
|
9
|
+
## 4.0.6
|
10
|
+
- Fix some documentation issues
|
11
|
+
|
12
|
+
## 4.0.5
|
13
|
+
- Docs: Add plugin description
|
14
|
+
|
15
|
+
## 4.0.4
|
16
|
+
- Docs: Fix plugin title
|
17
|
+
|
18
|
+
## 4.0.3
|
19
|
+
- Properly constrain mime types deps to be < 3.0 due to ruby 2.0+ requirement
|
20
|
+
- Uncap mail gem deps to play nicely with other plugins
|
21
|
+
|
22
|
+
## 4.0.2
|
23
|
+
- Relax constraint on logstash-core-plugin-api to >= 1.60 <= 2.99
|
24
|
+
|
25
|
+
## 4.0.1
|
26
|
+
- Republish all the gems under jruby.
|
27
|
+
## 4.0.0
|
28
|
+
- Update the plugin to the version 2.0 of the plugin api, this change is required for Logstash 5.0 compatibility. See https://github.com/elastic/logstash/issues/5141
|
29
|
+
# 3.0.5
|
30
|
+
- Depend on logstash-core-plugin-api instead of logstash-core, removing the need to mass update plugins on major releases of logstash
|
31
|
+
# 3.0.4
|
32
|
+
- Set the version of Mail to 2.6.3, since 2.6.4 has a dependency incompatible with jruby see https://github.com/elastic/logstash/issues/4883
|
33
|
+
|
34
|
+
# 3.0.3
|
35
|
+
- New dependency requirements for logstash-core for the 5.0 release
|
36
|
+
|
37
|
+
# 3.0.0
|
38
|
+
- Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
|
39
|
+
instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895
|
40
|
+
- Dependency on logstash-core update to 2.0
|
41
|
+
|
42
|
+
# 2.0.0
|
43
|
+
- Introduced new configuration options for the smtp server, the
|
44
|
+
options option is gone and now you need to specify each option
|
45
|
+
independetly. This require you to change your previous configuration
|
46
|
+
when updating.
|
47
|
+
- Removed the deprecated option match. This option was deprecatred in
|
48
|
+
favor of using conditionals. This change also require you to change
|
49
|
+
your current cnofiguration if using this option.
|
50
|
+
|
51
|
+
# 1.1.0
|
52
|
+
- Make the delivery method more reliable to failure by catching and
|
53
|
+
logging exceptions when happen, like this LS is not going to break
|
54
|
+
if something wrong happen, but is going to log it. Fixes #26 and #7
|
55
|
+
- Randomize port in specs so they can run in parallel.
|
data/CONTRIBUTORS
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
The following is a list of people who have contributed ideas, code, bug
|
2
|
+
reports, or in general have helped logstash along its way.
|
3
|
+
|
4
|
+
Contributors:
|
5
|
+
* Alexander Fortin (shaftoe)
|
6
|
+
* Colin Surprenant (colinsurprenant)
|
7
|
+
* Greg Mefford (GregMefford)
|
8
|
+
* James Turnbull (jamtur01)
|
9
|
+
* John E. Vincent (lusis)
|
10
|
+
* Jordan Sissel (jordansissel)
|
11
|
+
* Kurt Hurtado (kurtado)
|
12
|
+
* Kushal Pisavadia (KushalP)
|
13
|
+
* Nick Padilla (NickPadilla)
|
14
|
+
* Philippe Weber (wiibaa)
|
15
|
+
* Pier-Hugues Pellerin (ph)
|
16
|
+
* Richard Pijnenburg (electrical)
|
17
|
+
* Stian Mathiassen (smat)
|
18
|
+
* Tim Meighen (tmeighen)
|
19
|
+
|
20
|
+
Note: If you've sent us patches, bug reports, or otherwise contributed to
|
21
|
+
Logstash, and you aren't on the list above and want to be, please let us know
|
22
|
+
and we'll make sure you're here. Contributions from folks like you are what make
|
23
|
+
open source awesome.
|
data/Gemfile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
logstash_path = ENV["LOGSTASH_PATH"] || "../../logstash"
|
6
|
+
use_logstash_source = ENV["LOGSTASH_SOURCE"] && ENV["LOGSTASH_SOURCE"].to_s == "1"
|
7
|
+
|
8
|
+
if Dir.exist?(logstash_path) && use_logstash_source
|
9
|
+
gem 'logstash-core', :path => "#{logstash_path}/logstash-core"
|
10
|
+
gem 'logstash-core-plugin-api', :path => "#{logstash_path}/logstash-core-plugin-api"
|
11
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
|
2
|
+
Apache License
|
3
|
+
Version 2.0, January 2004
|
4
|
+
http://www.apache.org/licenses/
|
5
|
+
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
7
|
+
|
8
|
+
1. Definitions.
|
9
|
+
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
12
|
+
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
14
|
+
the copyright owner that is granting the License.
|
15
|
+
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
17
|
+
other entities that control, are controlled by, or are under common
|
18
|
+
control with that entity. For the purposes of this definition,
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
20
|
+
direction or management of such entity, whether by contract or
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
23
|
+
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
25
|
+
exercising permissions granted by this License.
|
26
|
+
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
28
|
+
including but not limited to software source code, documentation
|
29
|
+
source, and configuration files.
|
30
|
+
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
32
|
+
transformation or translation of a Source form, including but
|
33
|
+
not limited to compiled object code, generated documentation,
|
34
|
+
and conversions to other media types.
|
35
|
+
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
37
|
+
Object form, made available under the License, as indicated by a
|
38
|
+
copyright notice that is included in or attached to the work
|
39
|
+
(an example is provided in the Appendix below).
|
40
|
+
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
47
|
+
the Work and Derivative Works thereof.
|
48
|
+
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
50
|
+
the original version of the Work and any modifications or additions
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
62
|
+
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
65
|
+
subsequently incorporated within the Work.
|
66
|
+
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
73
|
+
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
79
|
+
where such license applies only to those patent claims licensable
|
80
|
+
by such Contributor that are necessarily infringed by their
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
83
|
+
institute patent litigation against any entity (including a
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
86
|
+
or contributory patent infringement, then any patent licenses
|
87
|
+
granted to You under this License for that Work shall terminate
|
88
|
+
as of the date such litigation is filed.
|
89
|
+
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
92
|
+
modifications, and in Source or Object form, provided that You
|
93
|
+
meet the following conditions:
|
94
|
+
|
95
|
+
(a) You must give any other recipients of the Work or
|
96
|
+
Derivative Works a copy of this License; and
|
97
|
+
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
99
|
+
stating that You changed the files; and
|
100
|
+
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
103
|
+
attribution notices from the Source form of the Work,
|
104
|
+
excluding those notices that do not pertain to any part of
|
105
|
+
the Derivative Works; and
|
106
|
+
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
109
|
+
include a readable copy of the attribution notices contained
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
112
|
+
of the following places: within a NOTICE text file distributed
|
113
|
+
as part of the Derivative Works; within the Source form or
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
115
|
+
within a display generated by the Derivative Works, if and
|
116
|
+
wherever such third-party notices normally appear. The contents
|
117
|
+
of the NOTICE file are for informational purposes only and
|
118
|
+
do not modify the License. You may add Your own attribution
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
121
|
+
that such additional attribution notices cannot be construed
|
122
|
+
as modifying the License.
|
123
|
+
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
125
|
+
may provide additional or different license terms and conditions
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
129
|
+
the conditions stated in this License.
|
130
|
+
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
134
|
+
this License, without any additional terms or conditions.
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
136
|
+
the terms of any separate license agreement you may have executed
|
137
|
+
with Licensor regarding such Contributions.
|
138
|
+
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
141
|
+
except as required for reasonable and customary use in describing the
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
143
|
+
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
153
|
+
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
159
|
+
incidental, or consequential damages of any character arising as a
|
160
|
+
result of this License or out of the use or inability to use the
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
163
|
+
other commercial damages or losses), even if such Contributor
|
164
|
+
has been advised of the possibility of such damages.
|
165
|
+
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
169
|
+
or other liability obligations and/or rights consistent with this
|
170
|
+
License. However, in accepting such obligations, You may act only
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
175
|
+
of your accepting any such warranty or additional liability.
|
176
|
+
|
177
|
+
END OF TERMS AND CONDITIONS
|
178
|
+
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
180
|
+
|
181
|
+
To apply the Apache License to your work, attach the following
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
183
|
+
replaced with your own identifying information. (Don't include
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
185
|
+
comment syntax for the file format. We also recommend that a
|
186
|
+
file or class name and description of purpose be included on the
|
187
|
+
same "printed page" as the copyright notice for easier
|
188
|
+
identification within third-party archives.
|
189
|
+
|
190
|
+
Copyright 2020 Elastic and contributors
|
191
|
+
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
193
|
+
you may not use this file except in compliance with the License.
|
194
|
+
You may obtain a copy of the License at
|
195
|
+
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
197
|
+
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
201
|
+
See the License for the specific language governing permissions and
|
202
|
+
limitations under the License.
|
data/NOTICE.TXT
ADDED
data/README.md
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
# Logstash Plugin
|
2
|
+
|
3
|
+
## Fork
|
4
|
+
|
5
|
+
This is a fork of the original [Logstash Mail Plugin](https://github.com/logstash-plugins/logstash-output-email).
|
6
|
+
It is published as `logstash-output-email2`.
|
7
|
+
|
8
|
+
|
9
|
+
[![Travis Build Status](https://travis-ci.com/kingjan1999/logstash-output-email.svg)](https://travis-ci.com/kingjan1999/logstash-output-email)
|
10
|
+
|
11
|
+
This is a plugin for [Logstash](https://github.com/elastic/logstash).
|
12
|
+
|
13
|
+
It is fully free and fully open source. The license is Apache 2.0, meaning you are pretty much free to use it however you want in whatever way.
|
14
|
+
|
15
|
+
## Documentation
|
16
|
+
|
17
|
+
Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elastic.co/guide/en/logstash/current/).
|
18
|
+
|
19
|
+
- For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
|
20
|
+
- For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
|
21
|
+
|
22
|
+
## Need Help?
|
23
|
+
|
24
|
+
Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
|
25
|
+
|
26
|
+
## Developing
|
27
|
+
|
28
|
+
### 1. Plugin Developement and Testing
|
29
|
+
|
30
|
+
#### Code
|
31
|
+
- To get started, you'll need JRuby with the Bundler gem installed.
|
32
|
+
|
33
|
+
- Create a new plugin or clone and existing from the GitHub [logstash-plugins](https://github.com/logstash-plugins) organization. We also provide [example plugins](https://github.com/logstash-plugins?query=example).
|
34
|
+
|
35
|
+
- Install dependencies
|
36
|
+
```sh
|
37
|
+
bundle install
|
38
|
+
```
|
39
|
+
|
40
|
+
#### Test
|
41
|
+
|
42
|
+
- Update your dependencies
|
43
|
+
|
44
|
+
```sh
|
45
|
+
bundle install
|
46
|
+
```
|
47
|
+
|
48
|
+
- Run tests
|
49
|
+
|
50
|
+
```sh
|
51
|
+
bundle exec rspec
|
52
|
+
```
|
53
|
+
|
54
|
+
### 2. Running your unpublished Plugin in Logstash
|
55
|
+
|
56
|
+
#### 2.1 Run in a local Logstash clone
|
57
|
+
|
58
|
+
- Edit Logstash `Gemfile` and add the local plugin path, for example:
|
59
|
+
```ruby
|
60
|
+
gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
|
61
|
+
```
|
62
|
+
- Install plugin
|
63
|
+
```sh
|
64
|
+
# Logstash 2.3 and higher
|
65
|
+
bin/logstash-plugin install --no-verify
|
66
|
+
|
67
|
+
# Prior to Logstash 2.3
|
68
|
+
bin/plugin install --no-verify
|
69
|
+
|
70
|
+
```
|
71
|
+
- Run Logstash with your plugin
|
72
|
+
```sh
|
73
|
+
bin/logstash -e 'filter {awesome {}}'
|
74
|
+
```
|
75
|
+
At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
|
76
|
+
|
77
|
+
#### 2.2 Run in an installed Logstash
|
78
|
+
|
79
|
+
You can use the same **2.1** method to run your plugin in an installed Logstash by editing its `Gemfile` and pointing the `:path` to your local plugin development directory or you can build the gem and install it using:
|
80
|
+
|
81
|
+
- Build your plugin gem
|
82
|
+
```sh
|
83
|
+
gem build logstash-filter-awesome.gemspec
|
84
|
+
```
|
85
|
+
- Install the plugin from the Logstash home
|
86
|
+
```sh
|
87
|
+
# Logstash 2.3 and higher
|
88
|
+
bin/logstash-plugin install --no-verify
|
89
|
+
|
90
|
+
# Prior to Logstash 2.3
|
91
|
+
bin/plugin install --no-verify
|
92
|
+
|
93
|
+
```
|
94
|
+
- Start Logstash and proceed to test the plugin
|
95
|
+
|
96
|
+
## Contributing
|
97
|
+
|
98
|
+
All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
|
99
|
+
|
100
|
+
Programming is not a required skill. Whatever you've seen about open source and maintainers or community members saying "send patches or die" - you will not see that here.
|
101
|
+
|
102
|
+
It is more important to the community that you are able to contribute.
|
103
|
+
|
104
|
+
For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
|
data/docs/index.asciidoc
ADDED
@@ -0,0 +1,259 @@
|
|
1
|
+
:plugin: email
|
2
|
+
:type: output
|
3
|
+
:default_codec: plain
|
4
|
+
|
5
|
+
///////////////////////////////////////////
|
6
|
+
START - GENERATED VARIABLES, DO NOT EDIT!
|
7
|
+
///////////////////////////////////////////
|
8
|
+
:version: %VERSION%
|
9
|
+
:release_date: %RELEASE_DATE%
|
10
|
+
:changelog_url: %CHANGELOG_URL%
|
11
|
+
:include_path: ../../../../logstash/docs/include
|
12
|
+
///////////////////////////////////////////
|
13
|
+
END - GENERATED VARIABLES, DO NOT EDIT!
|
14
|
+
///////////////////////////////////////////
|
15
|
+
|
16
|
+
[id="plugins-{type}s-{plugin}"]
|
17
|
+
|
18
|
+
=== Email output plugin
|
19
|
+
|
20
|
+
include::{include_path}/plugin_header.asciidoc[]
|
21
|
+
|
22
|
+
==== Description
|
23
|
+
|
24
|
+
Sends email when an output is received. Alternatively, you may include or
|
25
|
+
exclude the email output execution using conditionals.
|
26
|
+
|
27
|
+
==== Usage Example
|
28
|
+
[source,ruby]
|
29
|
+
----------------------------------
|
30
|
+
output {
|
31
|
+
if "shouldmail" in [tags] {
|
32
|
+
email {
|
33
|
+
to => 'technical@example.com'
|
34
|
+
from => 'monitor@example.com'
|
35
|
+
subject => 'Alert - %{title}'
|
36
|
+
body => "Tags: %{tags}\\n\\Content:\\n%{message}"
|
37
|
+
template_file => "/tmp/email_template.mustache"
|
38
|
+
domain => 'mail.example.com'
|
39
|
+
port => 25
|
40
|
+
}
|
41
|
+
}
|
42
|
+
}
|
43
|
+
----------------------------------
|
44
|
+
|
45
|
+
[id="plugins-{type}s-{plugin}-options"]
|
46
|
+
==== Email Output Configuration Options
|
47
|
+
|
48
|
+
This plugin supports the following configuration options plus the <<plugins-{type}s-{plugin}-common-options>> described later.
|
49
|
+
|
50
|
+
[cols="<,<,<",options="header",]
|
51
|
+
|=======================================================================
|
52
|
+
|Setting |Input type|Required
|
53
|
+
| <<plugins-{type}s-{plugin}-address>> |<<string,string>>|No
|
54
|
+
| <<plugins-{type}s-{plugin}-attachments>> |<<array,array>>|No
|
55
|
+
| <<plugins-{type}s-{plugin}-authentication>> |<<string,string>>|No
|
56
|
+
| <<plugins-{type}s-{plugin}-body>> |<<string,string>>|No
|
57
|
+
| <<plugins-{type}s-{plugin}-cc>> |<<string,string>>|No
|
58
|
+
| <<plugins-{type}s-{plugin}-bcc>> |<<string,string>>|No
|
59
|
+
| <<plugins-{type}s-{plugin}-contenttype>> |<<string,string>>|No
|
60
|
+
| <<plugins-{type}s-{plugin}-debug>> |<<boolean,boolean>>|No
|
61
|
+
| <<plugins-{type}s-{plugin}-domain>> |<<string,string>>|No
|
62
|
+
| <<plugins-{type}s-{plugin}-from>> |<<string,string>>|No
|
63
|
+
| <<plugins-{type}s-{plugin}-htmlbody>> |<<string,string>>|No
|
64
|
+
| <<plugins-{type}s-{plugin}-password>> |<<string,string>>|No
|
65
|
+
| <<plugins-{type}s-{plugin}-port>> |<<number,number>>|No
|
66
|
+
| <<plugins-{type}s-{plugin}-replyto>> |<<string,string>>|No
|
67
|
+
| <<plugins-{type}s-{plugin}-subject>> |<<string,string>>|No
|
68
|
+
| <<plugins-{type}s-{plugin}-to>> |<<string,string>>|Yes
|
69
|
+
| <<plugins-{type}s-{plugin}-use_tls>> |<<boolean,boolean>>|No
|
70
|
+
| <<plugins-{type}s-{plugin}-username>> |<<string,string>>|No
|
71
|
+
| <<plugins-{type}s-{plugin}-via>> |<<string,string>>|No
|
72
|
+
| <<plugins-{type}s-{plugin}-template_file>> |<<path,path>>|No
|
73
|
+
|=======================================================================
|
74
|
+
|
75
|
+
Also see <<plugins-{type}s-{plugin}-common-options>> for a list of options supported by all
|
76
|
+
output plugins.
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
[id="plugins-{type}s-{plugin}-address"]
|
81
|
+
===== `address`
|
82
|
+
|
83
|
+
* Value type is <<string,string>>
|
84
|
+
* Default value is `"localhost"`
|
85
|
+
|
86
|
+
The address used to connect to the mail server
|
87
|
+
|
88
|
+
[id="plugins-{type}s-{plugin}-attachments"]
|
89
|
+
===== `attachments`
|
90
|
+
|
91
|
+
* Value type is <<array,array>>
|
92
|
+
* Default value is `[]`
|
93
|
+
|
94
|
+
Attachments - specify the name(s) and location(s) of the files.
|
95
|
+
|
96
|
+
[id="plugins-{type}s-{plugin}-authentication"]
|
97
|
+
===== `authentication`
|
98
|
+
|
99
|
+
* Value type is <<string,string>>
|
100
|
+
* There is no default value for this setting.
|
101
|
+
|
102
|
+
Authentication method used when identifying with the server
|
103
|
+
|
104
|
+
[id="plugins-{type}s-{plugin}-body"]
|
105
|
+
===== `body`
|
106
|
+
|
107
|
+
* Value type is <<string,string>>
|
108
|
+
* Default value is `""`
|
109
|
+
|
110
|
+
Body for the email - plain text only.
|
111
|
+
|
112
|
+
[id="plugins-{type}s-{plugin}-cc"]
|
113
|
+
===== `cc`
|
114
|
+
|
115
|
+
* Value type is <<string,string>>
|
116
|
+
* There is no default value for this setting.
|
117
|
+
|
118
|
+
The fully-qualified email address(es) to include as cc: address(es).
|
119
|
+
|
120
|
+
This field also accepts a comma-separated string of addresses, for example:
|
121
|
+
`"me@example.com, you@example.com"`
|
122
|
+
|
123
|
+
[id="plugins-{type}s-{plugin}-bcc"]
|
124
|
+
===== `bcc`
|
125
|
+
|
126
|
+
* Value type is <<string,string>>
|
127
|
+
* There is no default value for this setting.
|
128
|
+
|
129
|
+
The fully-qualified email address(es) to include as bcc: address(es).
|
130
|
+
|
131
|
+
This field accepts several addresses like cc.
|
132
|
+
|
133
|
+
[id="plugins-{type}s-{plugin}-contenttype"]
|
134
|
+
===== `contenttype`
|
135
|
+
|
136
|
+
* Value type is <<string,string>>
|
137
|
+
* Default value is `"text/html; charset=UTF-8"`
|
138
|
+
|
139
|
+
contenttype : for multipart messages, set the content-type and/or charset of the HTML part.
|
140
|
+
NOTE: this may not be functional (KH)
|
141
|
+
|
142
|
+
[id="plugins-{type}s-{plugin}-debug"]
|
143
|
+
===== `debug`
|
144
|
+
|
145
|
+
* Value type is <<boolean,boolean>>
|
146
|
+
* Default value is `false`
|
147
|
+
|
148
|
+
Run the mail relay in debug mode
|
149
|
+
|
150
|
+
[id="plugins-{type}s-{plugin}-domain"]
|
151
|
+
===== `domain`
|
152
|
+
|
153
|
+
* Value type is <<string,string>>
|
154
|
+
* Default value is `"localhost"`
|
155
|
+
|
156
|
+
The HELO/EHLO domain name used in the greeting message when connecting
|
157
|
+
to a remote SMTP server. Some servers require this name to match the
|
158
|
+
actual hostname of the connecting client.
|
159
|
+
|
160
|
+
[id="plugins-{type}s-{plugin}-from"]
|
161
|
+
===== `from`
|
162
|
+
|
163
|
+
* Value type is <<string,string>>
|
164
|
+
* Default value is `"logstash.alert@example.com"`
|
165
|
+
|
166
|
+
The fully-qualified email address for the From: field in the email.
|
167
|
+
|
168
|
+
[id="plugins-{type}s-{plugin}-htmlbody"]
|
169
|
+
===== `htmlbody`
|
170
|
+
|
171
|
+
* Value type is <<string,string>>
|
172
|
+
* Default value is `""`
|
173
|
+
|
174
|
+
HTML Body for the email, which may contain HTML markup.
|
175
|
+
|
176
|
+
[id="plugins-{type}s-{plugin}-password"]
|
177
|
+
===== `password`
|
178
|
+
|
179
|
+
* Value type is <<string,string>>
|
180
|
+
* There is no default value for this setting.
|
181
|
+
|
182
|
+
Password to authenticate with the server
|
183
|
+
|
184
|
+
[id="plugins-{type}s-{plugin}-port"]
|
185
|
+
===== `port`
|
186
|
+
|
187
|
+
* Value type is <<number,number>>
|
188
|
+
* Default value is `25`
|
189
|
+
|
190
|
+
Port used to communicate with the mail server
|
191
|
+
|
192
|
+
[id="plugins-{type}s-{plugin}-replyto"]
|
193
|
+
===== `replyto`
|
194
|
+
|
195
|
+
* Value type is <<string,string>>
|
196
|
+
* There is no default value for this setting.
|
197
|
+
|
198
|
+
The fully qualified email address for the Reply-To: field.
|
199
|
+
|
200
|
+
[id="plugins-{type}s-{plugin}-subject"]
|
201
|
+
===== `subject`
|
202
|
+
|
203
|
+
* Value type is <<string,string>>
|
204
|
+
* Default value is `""`
|
205
|
+
|
206
|
+
Subject: for the email.
|
207
|
+
|
208
|
+
[id="plugins-{type}s-{plugin}-to"]
|
209
|
+
===== `to`
|
210
|
+
|
211
|
+
* This is a required setting.
|
212
|
+
* Value type is <<string,string>>
|
213
|
+
* There is no default value for this setting.
|
214
|
+
|
215
|
+
The fully-qualified email address to send the email to.
|
216
|
+
|
217
|
+
This field also accepts a comma-separated string of addresses, for example:
|
218
|
+
`"me@example.com, you@example.com"`
|
219
|
+
|
220
|
+
You can also use dynamic fields from the event with the `%{fieldname}` syntax.
|
221
|
+
|
222
|
+
[id="plugins-{type}s-{plugin}-use_tls"]
|
223
|
+
===== `use_tls`
|
224
|
+
|
225
|
+
* Value type is <<boolean,boolean>>
|
226
|
+
* Default value is `false`
|
227
|
+
|
228
|
+
Enables TLS when communicating with the server
|
229
|
+
|
230
|
+
[id="plugins-{type}s-{plugin}-username"]
|
231
|
+
===== `username`
|
232
|
+
|
233
|
+
* Value type is <<string,string>>
|
234
|
+
* There is no default value for this setting.
|
235
|
+
|
236
|
+
Username to authenticate with the server
|
237
|
+
|
238
|
+
[id="plugins-{type}s-{plugin}-via"]
|
239
|
+
===== `via`
|
240
|
+
|
241
|
+
* Value type is <<string,string>>
|
242
|
+
* Default value is `"smtp"`
|
243
|
+
|
244
|
+
How Logstash should send the email, either via SMTP or by invoking sendmail.
|
245
|
+
|
246
|
+
[id="plugins-{type}s-{plugin}-template_file"]
|
247
|
+
===== `template_file`
|
248
|
+
|
249
|
+
* Value type is <<path,path>>
|
250
|
+
* There is no default value for this setting.
|
251
|
+
|
252
|
+
Path of a [Mustache templating](https://mustache.github.io/) file used for email templating. See example in test fixture.
|
253
|
+
Can be used with `body` to send multi-part emails. Takes precedence over `htmlBody`.
|
254
|
+
|
255
|
+
|
256
|
+
[id="plugins-{type}s-{plugin}-common-options"]
|
257
|
+
include::{include_path}/{type}.asciidoc[]
|
258
|
+
|
259
|
+
:default_codec!:
|
@@ -0,0 +1,194 @@
|
|
1
|
+
#
|
2
|
+
# ==== Usage Example
|
3
|
+
|
4
|
+
# [source,ruby]
|
5
|
+
# ----------------------------------
|
6
|
+
# output {
|
7
|
+
# if "shouldmail" in [tags] {
|
8
|
+
# email {
|
9
|
+
# to => 'technical@example.com'
|
10
|
+
# from => 'monitor@example.com'
|
11
|
+
# subject => 'Alert - %{title}'
|
12
|
+
# body => "Tags: %{tags}\\n\\Content:\\n%{message}"
|
13
|
+
# domain => 'mail.example.com'
|
14
|
+
# port => 25
|
15
|
+
# }
|
16
|
+
# }
|
17
|
+
# }
|
18
|
+
# ----------------------------------
|
19
|
+
|
20
|
+
# encoding: utf-8
|
21
|
+
require "logstash/outputs/base"
|
22
|
+
require "logstash/namespace"
|
23
|
+
|
24
|
+
# Send email when an output is received. Alternatively, you may include or
|
25
|
+
# exclude the email output execution using conditionals.
|
26
|
+
class LogStash::Outputs::Email < LogStash::Outputs::Base
|
27
|
+
|
28
|
+
config_name "email"
|
29
|
+
|
30
|
+
# The fully-qualified email address to send the email to.
|
31
|
+
#
|
32
|
+
# This field also accepts a comma-separated string of addresses, for example:
|
33
|
+
# `"me@example.com, you@example.com"`
|
34
|
+
#
|
35
|
+
# You can also use dynamic fields from the event with the `%{fieldname}` syntax.
|
36
|
+
config :to, :validate => :string, :required => true
|
37
|
+
|
38
|
+
# The fully-qualified email address for the From: field in the email.
|
39
|
+
config :from, :validate => :string, :default => "logstash.alert@example.com"
|
40
|
+
|
41
|
+
# The fully qualified email address for the Reply-To: field.
|
42
|
+
config :replyto, :validate => :string
|
43
|
+
|
44
|
+
# The fully-qualified email address(es) to include as cc: address(es).
|
45
|
+
#
|
46
|
+
# This field also accepts a comma-separated string of addresses, for example:
|
47
|
+
# `"me@example.com, you@example.com"`
|
48
|
+
config :cc, :validate => :string
|
49
|
+
|
50
|
+
# Same as cc but in blind carbon
|
51
|
+
config :bcc, :validate => :string
|
52
|
+
|
53
|
+
# How Logstash should send the email, either via SMTP or by invoking sendmail.
|
54
|
+
config :via, :validate => :string, :default => "smtp"
|
55
|
+
|
56
|
+
# The address used to connect to the mail server
|
57
|
+
config :address, :validate => :string, :default => "localhost"
|
58
|
+
|
59
|
+
# Port used to communicate with the mail server
|
60
|
+
config :port, :validate => :number, :default => 25
|
61
|
+
|
62
|
+
# HELO/EHLO domain name
|
63
|
+
config :domain, :validate => :string, :default => "localhost"
|
64
|
+
|
65
|
+
# Username to authenticate with the server
|
66
|
+
config :username, :validate => :string
|
67
|
+
|
68
|
+
# Password to authenticate with the server
|
69
|
+
config :password, :validate => :string
|
70
|
+
|
71
|
+
# Authentication method used when identifying with the server
|
72
|
+
config :authentication, :validate => :string
|
73
|
+
|
74
|
+
# Enables TLS when communicating with the server
|
75
|
+
config :use_tls, :validate => :boolean, :default => false
|
76
|
+
|
77
|
+
# Run the mail relay in debug mode
|
78
|
+
config :debug, :validate => :boolean, :default => false
|
79
|
+
|
80
|
+
# Subject: for the email.
|
81
|
+
config :subject, :validate => :string, :default => ""
|
82
|
+
|
83
|
+
# Body for the email - plain text only.
|
84
|
+
config :body, :validate => :string, :default => ""
|
85
|
+
|
86
|
+
# Email template file to be used - as mustache template.
|
87
|
+
config :template_file, :validate => :path
|
88
|
+
|
89
|
+
# HTML Body for the email, which may contain HTML markup.
|
90
|
+
config :htmlbody, :validate => :string, :default => ""
|
91
|
+
|
92
|
+
# Attachments - specify the name(s) and location(s) of the files.
|
93
|
+
config :attachments, :validate => :array, :default => []
|
94
|
+
|
95
|
+
# contenttype : for multipart messages, set the content-type and/or charset of the HTML part.
|
96
|
+
# NOTE: this may not be functional (KH)
|
97
|
+
config :contenttype, :validate => :string, :default => "text/html; charset=UTF-8"
|
98
|
+
|
99
|
+
# Custom headers to attach to the email
|
100
|
+
config :custom_headers, :validate => :hash, :default => {}
|
101
|
+
|
102
|
+
public
|
103
|
+
def register
|
104
|
+
require "mail"
|
105
|
+
require "mustache"
|
106
|
+
|
107
|
+
options = {
|
108
|
+
:address => @address,
|
109
|
+
:port => @port,
|
110
|
+
:domain => @domain,
|
111
|
+
:user_name => @username,
|
112
|
+
:password => @password,
|
113
|
+
:authentication => @authentication,
|
114
|
+
:enable_starttls_auto => @use_tls,
|
115
|
+
:debug => @debug
|
116
|
+
}
|
117
|
+
|
118
|
+
if @via == "smtp"
|
119
|
+
Mail.defaults do
|
120
|
+
delivery_method :smtp, options
|
121
|
+
end
|
122
|
+
elsif @via == 'sendmail'
|
123
|
+
Mail.defaults do
|
124
|
+
delivery_method :sendmail
|
125
|
+
end
|
126
|
+
else
|
127
|
+
Mail.defaults do
|
128
|
+
delivery_method :@via, options
|
129
|
+
end
|
130
|
+
end # @via tests
|
131
|
+
@htmlTemplate = File.open(@template_file, "r").read unless @template_file.nil?
|
132
|
+
@logger.debug("Email Output Registered!", :config => options, :via => @via)
|
133
|
+
end # def register
|
134
|
+
|
135
|
+
public
|
136
|
+
def receive(event)
|
137
|
+
|
138
|
+
|
139
|
+
@logger.debug? and @logger.debug("Creating mail with these settings : ", :via => @via, :options => @options, :from => @from, :to => @to, :cc => @cc, :bcc => @bcc, :subject => @subject, :body => @body, :content_type => @contenttype, :htmlbody => @htmlbody, :attachments => @attachments, :custom_headers => @custom_headers)
|
140
|
+
formatedSubject = event.sprintf(@subject)
|
141
|
+
formattedBody = event.sprintf(@body)
|
142
|
+
formattedHtmlBody = event.sprintf(@htmlbody)
|
143
|
+
|
144
|
+
mail = Mail.new
|
145
|
+
mail.from = event.sprintf(@from)
|
146
|
+
mail.to = event.sprintf(@to)
|
147
|
+
if @replyto
|
148
|
+
mail.reply_to = event.sprintf(@replyto)
|
149
|
+
end
|
150
|
+
mail.cc = event.sprintf(@cc)
|
151
|
+
mail.bcc = event.sprintf(@bcc)
|
152
|
+
mail.subject = formatedSubject
|
153
|
+
|
154
|
+
@custom_headers.each do |key, value|
|
155
|
+
mail.header[event.sprintf(key)] = event.sprintf(value)
|
156
|
+
end
|
157
|
+
|
158
|
+
if @htmlbody.empty? and @template_file.nil?
|
159
|
+
formattedBody.gsub!(/\\n/, "\n") # Take new line in the email
|
160
|
+
mail.body = formattedBody
|
161
|
+
else
|
162
|
+
# This handles multipart emails
|
163
|
+
# cf: https://github.com/mikel/mail/#writing-and-sending-a-multipartalternative-html-and-text-email
|
164
|
+
mail.text_part = Mail::Part.new do
|
165
|
+
content_type "text/plain; charset=UTF-8"
|
166
|
+
formattedBody.gsub!(/\\n/, "\n") # Take new line in the email
|
167
|
+
body formattedBody
|
168
|
+
end
|
169
|
+
|
170
|
+
if @template_file.nil?
|
171
|
+
mail.html_part = Mail::Part.new do
|
172
|
+
content_type "text/html; charset=UTF-8"
|
173
|
+
body formattedHtmlBody
|
174
|
+
end
|
175
|
+
else
|
176
|
+
templatedHtmlBody = Mustache.render(@htmlTemplate, event.to_hash)
|
177
|
+
mail.html_part = Mail::Part.new do
|
178
|
+
content_type "text/html; charset=UTF-8"
|
179
|
+
body templatedHtmlBody
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
@attachments.each do |fileLocation|
|
184
|
+
mail.add_file(fileLocation)
|
185
|
+
end # end @attachments.each
|
186
|
+
@logger.debug? and @logger.debug("Sending mail with these values : ", :from => mail.from, :to => mail.to, :cc => mail.cc, :bcc => mail.bcc, :subject => mail.subject)
|
187
|
+
begin
|
188
|
+
mail.deliver!
|
189
|
+
rescue StandardError => e
|
190
|
+
@logger.error("Something happen while delivering an email", :exception => e)
|
191
|
+
@logger.debug? && @logger.debug("Processed event: ", :event => event)
|
192
|
+
end
|
193
|
+
end # def receive
|
194
|
+
end # class LogStash::Outputs::Email
|
@@ -0,0 +1,37 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
|
3
|
+
s.name = 'logstash-output-email-v2'
|
4
|
+
s.version = '4.2.0'
|
5
|
+
s.licenses = ['Apache License (2.0)']
|
6
|
+
s.summary = "Sends email to a specified address when output is received"
|
7
|
+
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
|
8
|
+
s.authors = ["Elastic", "kingjan1999"]
|
9
|
+
s.email = 'info@elastic.co'
|
10
|
+
s.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html"
|
11
|
+
s.require_paths = ["lib"]
|
12
|
+
|
13
|
+
# Files
|
14
|
+
s.files = Dir["lib/**/*","spec/**/*","*.gemspec","*.md","CONTRIBUTORS","Gemfile","LICENSE","NOTICE.TXT", "vendor/jar-dependencies/**/*.jar", "vendor/jar-dependencies/**/*.rb", "VERSION", "docs/**/*"]
|
15
|
+
|
16
|
+
# Tests
|
17
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
18
|
+
|
19
|
+
# Special flag to let us know this is actually a logstash plugin
|
20
|
+
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "output" }
|
21
|
+
|
22
|
+
# Gem dependencies
|
23
|
+
s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
|
24
|
+
|
25
|
+
s.add_runtime_dependency 'mail', '~> 2.7.1'
|
26
|
+
# mime-types >= 3 require ruby 2.0 support
|
27
|
+
s.add_runtime_dependency 'mime-types', '< 3'
|
28
|
+
|
29
|
+
s.add_runtime_dependency 'mustache', '>= 0.99.8'
|
30
|
+
|
31
|
+
s.add_development_dependency 'logstash-devutils'
|
32
|
+
s.add_development_dependency 'rumbster'
|
33
|
+
s.add_development_dependency 'logstash-input-generator'
|
34
|
+
s.add_development_dependency 'gserver'
|
35
|
+
|
36
|
+
end
|
37
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
<h1>{{message}}</h1>
|
@@ -0,0 +1,125 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "spec_helper"
|
3
|
+
require "rumbster"
|
4
|
+
require "message_observers"
|
5
|
+
|
6
|
+
describe "outputs/email" do
|
7
|
+
|
8
|
+
let (:port) { rand(1024..65535) }
|
9
|
+
let (:rumbster) { Rumbster.new(port) }
|
10
|
+
let (:message_observer) { MailMessageObserver.new }
|
11
|
+
let(:plugin) { LogStash::Plugin.lookup("output", "email") }
|
12
|
+
|
13
|
+
|
14
|
+
before :each do
|
15
|
+
rumbster.add_observer message_observer
|
16
|
+
rumbster.start
|
17
|
+
end
|
18
|
+
|
19
|
+
after :each do
|
20
|
+
rumbster.stop
|
21
|
+
sleep 0.01 until rumbster.stopped?
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "send email" do
|
25
|
+
|
26
|
+
context "use a list of email as mail.to (LOGSTASH-827)" do
|
27
|
+
|
28
|
+
it "supports list of emails in to field" do
|
29
|
+
subject = plugin.new("to" => ["email1@host, email2@host"],
|
30
|
+
"port" => port)
|
31
|
+
subject.register
|
32
|
+
subject.receive(LogStash::Event.new("message" => "hello"))
|
33
|
+
expect(message_observer.messages.size).to eq(1)
|
34
|
+
expect(message_observer.messages[0].to).to eq(["email1@host", "email2@host"])
|
35
|
+
end
|
36
|
+
|
37
|
+
it "multiple *to* addresses in a field" do
|
38
|
+
subject = plugin.new("to" => "%{to_addr}",
|
39
|
+
"port" => port)
|
40
|
+
subject.register
|
41
|
+
subject.receive(LogStash::Event.new("message" => "hello",
|
42
|
+
"to_addr" => ["email1@host", "email2@host"]))
|
43
|
+
expect(message_observer.messages.size).to eq(1)
|
44
|
+
expect(message_observer.messages[0].to).to eq(["email1@host", "email2@host"])
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
context "multi-lined text body (LOGSTASH-841)" do
|
50
|
+
it "handles multiline messages" do
|
51
|
+
subject = plugin.new("to" => "me@host",
|
52
|
+
"subject" => "Hello World",
|
53
|
+
"body" => "Line1\\nLine2\\nLine3",
|
54
|
+
"port" => port)
|
55
|
+
subject.register
|
56
|
+
subject.receive(LogStash::Event.new("message" => "hello"))
|
57
|
+
expect(message_observer.messages.size).to eq(1)
|
58
|
+
expect(message_observer.messages[0].subject).to eq("Hello World")
|
59
|
+
expect(message_observer.messages[0].body.raw_source).to eq("Line1\r\nLine2\r\nLine3\r\n")
|
60
|
+
end
|
61
|
+
|
62
|
+
context "use nil authenticationType (LOGSTASH-559)" do
|
63
|
+
it "reads messages correctly" do
|
64
|
+
subject = plugin.new("to" => "me@host",
|
65
|
+
"subject" => "Hello World",
|
66
|
+
"body" => "Line1\\nLine2\\nLine3",
|
67
|
+
"port" => port)
|
68
|
+
subject.register
|
69
|
+
subject.receive(LogStash::Event.new("message" => "hello"))
|
70
|
+
expect(message_observer.messages.size).to eq(1)
|
71
|
+
expect(message_observer.messages[0].subject).to eq("Hello World")
|
72
|
+
expect(message_observer.messages[0].body.raw_source).to eq("Line1\r\nLine2\r\nLine3\r\n")
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
context "having no connection to the email server" do
|
77
|
+
|
78
|
+
subject { plugin.new("to" => "me@host") }
|
79
|
+
let(:event) { LogStash::Event.new("message" => "hello world") }
|
80
|
+
|
81
|
+
before(:each) do
|
82
|
+
subject.register
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should send without throwing an error" do
|
86
|
+
expect { subject.receive(event) }.not_to raise_error
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
context "mustache template for email body" do
|
94
|
+
it "uses the template file" do
|
95
|
+
subject = plugin.new("to" => "me@host",
|
96
|
+
"subject" => "Hello World",
|
97
|
+
"template_file" => File.dirname(__FILE__) + "/../fixtures/template.mustache",
|
98
|
+
"port" => port)
|
99
|
+
subject.register
|
100
|
+
subject.receive(LogStash::Event.new("message" => "hello"))
|
101
|
+
|
102
|
+
expect(message_observer.messages.size).to eq(1)
|
103
|
+
expect(message_observer.messages[0].subject).to eq("Hello World")
|
104
|
+
expect(message_observer.messages[0].body.decoded).to eq(craft_multi_part_email('', '<h1>hello</h1>', message_observer.messages[0].content_type))
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
context "custom headers for email" do
|
109
|
+
it "adds custom headers" do
|
110
|
+
headers = { "header_1" => "header_1_value", "header_2" => "header_2_value" }
|
111
|
+
subject = plugin.new("to" => "me@host",
|
112
|
+
"subject" => "Hello World",
|
113
|
+
"body" => "Line1\\nLine2\\nLine3",
|
114
|
+
"port" => port,
|
115
|
+
"custom_headers" => headers )
|
116
|
+
subject.register
|
117
|
+
subject.receive(LogStash::Event.new("message" => "hello"))
|
118
|
+
expect(message_observer.messages.size).to eq(1)
|
119
|
+
headers.each do |key, value|
|
120
|
+
expect(message_observer.messages[0].header[key].value).to eq(value)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require "logstash/devutils/rspec/spec_helper"
|
2
|
+
|
3
|
+
# use a dummy NOOP filter to test Filters::Base
|
4
|
+
class LogStash::Filters::NOOP < LogStash::Filters::Base
|
5
|
+
config_name "noop"
|
6
|
+
milestone 2
|
7
|
+
|
8
|
+
def register; end
|
9
|
+
|
10
|
+
def filter(event)
|
11
|
+
|
12
|
+
filter_matched(event)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def craft_multi_part_email(body, htmlbody, content_type)
|
17
|
+
charset = "charset=UTF-8"
|
18
|
+
content_encoding = "Content-Transfer-Encoding: 7bit"
|
19
|
+
|
20
|
+
# Have to get the generated part of the header, eg:
|
21
|
+
# --==_mimepart_5a462a1fda04b_efe7d032127
|
22
|
+
mimetype = content_type.split('; ')[1][10..-2]
|
23
|
+
|
24
|
+
plain_header = "\n--#{mimetype}\nContent-Type: text/plain;\n #{charset}\n#{content_encoding}\n\n"
|
25
|
+
html_header = "\n--#{mimetype}\nContent-Type: text/html;\n #{charset}\n#{content_encoding}\n\n"
|
26
|
+
|
27
|
+
"#{plain_header}#{body}#{html_header}#{htmlbody}\n\n--#{mimetype}--\n"
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,180 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: logstash-output-email-v2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 4.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Elastic
|
8
|
+
- kingjan1999
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2021-10-07 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.60'
|
20
|
+
- - "<="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '2.99'
|
23
|
+
name: logstash-core-plugin-api
|
24
|
+
prerelease: false
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: !ruby/object:Gem::Requirement
|
27
|
+
requirements:
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '1.60'
|
31
|
+
- - "<="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.99'
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 2.7.1
|
40
|
+
name: mail
|
41
|
+
prerelease: false
|
42
|
+
type: :runtime
|
43
|
+
version_requirements: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.7.1
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "<"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '3'
|
54
|
+
name: mime-types
|
55
|
+
prerelease: false
|
56
|
+
type: :runtime
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "<"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 0.99.8
|
68
|
+
name: mustache
|
69
|
+
prerelease: false
|
70
|
+
type: :runtime
|
71
|
+
version_requirements: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.99.8
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
name: logstash-devutils
|
83
|
+
prerelease: false
|
84
|
+
type: :development
|
85
|
+
version_requirements: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
- !ruby/object:Gem::Dependency
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
name: rumbster
|
97
|
+
prerelease: false
|
98
|
+
type: :development
|
99
|
+
version_requirements: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
- !ruby/object:Gem::Dependency
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
name: logstash-input-generator
|
111
|
+
prerelease: false
|
112
|
+
type: :development
|
113
|
+
version_requirements: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
- !ruby/object:Gem::Dependency
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
name: gserver
|
125
|
+
prerelease: false
|
126
|
+
type: :development
|
127
|
+
version_requirements: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
description: This gem is a Logstash plugin required to be installed on top of the
|
133
|
+
Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This
|
134
|
+
gem is not a stand-alone program
|
135
|
+
email: info@elastic.co
|
136
|
+
executables: []
|
137
|
+
extensions: []
|
138
|
+
extra_rdoc_files: []
|
139
|
+
files:
|
140
|
+
- CHANGELOG.md
|
141
|
+
- CONTRIBUTORS
|
142
|
+
- Gemfile
|
143
|
+
- LICENSE
|
144
|
+
- NOTICE.TXT
|
145
|
+
- README.md
|
146
|
+
- docs/index.asciidoc
|
147
|
+
- lib/logstash/outputs/email.rb
|
148
|
+
- logstash-output-email.gemspec
|
149
|
+
- spec/fixtures/template.mustache
|
150
|
+
- spec/outputs/email_spec.rb
|
151
|
+
- spec/spec_helper.rb
|
152
|
+
homepage: http://www.elastic.co/guide/en/logstash/current/index.html
|
153
|
+
licenses:
|
154
|
+
- Apache License (2.0)
|
155
|
+
metadata:
|
156
|
+
logstash_plugin: 'true'
|
157
|
+
logstash_group: output
|
158
|
+
post_install_message:
|
159
|
+
rdoc_options: []
|
160
|
+
require_paths:
|
161
|
+
- lib
|
162
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
168
|
+
requirements:
|
169
|
+
- - ">="
|
170
|
+
- !ruby/object:Gem::Version
|
171
|
+
version: '0'
|
172
|
+
requirements: []
|
173
|
+
rubygems_version: 3.2.14
|
174
|
+
signing_key:
|
175
|
+
specification_version: 4
|
176
|
+
summary: Sends email to a specified address when output is received
|
177
|
+
test_files:
|
178
|
+
- spec/fixtures/template.mustache
|
179
|
+
- spec/outputs/email_spec.rb
|
180
|
+
- spec/spec_helper.rb
|