forked from elastic/built-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactions-email.html
883 lines (860 loc) · 47.3 KB
/
actions-email.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="UTF-8">
<title>Email action | Elasticsearch Guide [7.3] | Elastic</title>
<meta class="elastic" name="content" content="Email action | Elasticsearch Guide [7.3]">
<link rel="home" href="index.html" title="Elasticsearch Guide [7.3]"/>
<link rel="up" href="actions.html" title="Actions"/>
<link rel="prev" href="action-conditions.html" title="Adding conditions to actions"/>
<link rel="next" href="actions-webhook.html" title="Webhook action"/>
<meta class="elastic" name="product_version" content="7.3"/>
<meta class="elastic" name="product_name" content="Elasticsearch"/>
<meta class="elastic" name="website_area" content="documentation"/>
<meta name="DC.type" content="Learn/Docs/Elasticsearch/Reference/7.3"/>
<meta name="DC.subject" content="Elasticsearch"/>
<meta name="DC.identifier" content="7.3"/>
<meta name="robots" content="noindex,nofollow"/>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://cdn.optimizely.com/js/18132920325.js"></script>
<link rel="apple-touch-icon" sizes="57x57" href="/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-icon-180x180.png">
<link rel="icon" type="image/png" href="/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="/android-chrome-192x192.png" sizes="192x192">
<link rel="icon" type="image/png" href="/favicon-96x96.png" sizes="96x96">
<link rel="icon" type="image/png" href="/favicon-16x16.png" sizes="16x16">
<link rel="manifest" href="/manifest.json">
<meta name="apple-mobile-web-app-title" content="Elastic">
<meta name="application-name" content="Elastic">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-TileImage" content="/mstile-144x144.png">
<meta name="theme-color" content="#ffffff">
<meta name="naver-site-verification" content="936882c1853b701b3cef3721758d80535413dbfd" />
<meta name="yandex-verification" content="d8a47e95d0972434" />
<meta name="localized" content="true" />
<meta name="st:robots" content="follow,index" />
<meta property="og:image" content="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt280217a63b82a734/6202d3378b1f312528798412/elastic-logo.svg" />
<meta property="og:image:width" content="500" />
<meta property="og:image:height" content="172" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
<link rel="icon" href="/favicon.ico" type="image/x-icon">
<link rel="apple-touch-icon-precomposed" sizes="64x64" href="/favicon_64x64_16bit.png">
<link rel="apple-touch-icon-precomposed" sizes="32x32" href="/favicon_32x32.png">
<link rel="apple-touch-icon-precomposed" sizes="16x16" href="/favicon_16x16.png">
<!-- Give IE8 a fighting chance -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="/guide/static/styles.css" />
</head>
<!--© 2015-2022 Elasticsearch B.V. -->
<!-- All Elastic documentation is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. -->
<!-- http://creativecommons.org/licenses/by-nc-nd/4.0/ -->
<body>
<!-- Google Tag Manager -->
<script>dataLayer = [];</script><noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-58RLH5" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-58RLH5');</script>
<!-- End Google Tag Manager -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-12395217-16"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-12395217-16');
</script>
<!-- Google Tag Manager for GA4 -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-KNJMG2M');</script>
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-KNJMG2M" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager for GA4-->
<div id='elastic-nav' style="display:none;"></div>
<script src='https://www.elastic.co/elastic-nav.js'></script>
<div class="main-container">
<section id="content" >
<div class="content-wrapper">
<section id="guide" lang="en">
<div class="container-fluid">
<div class="row pb-3">
<div class="col-12 order-2 col-md-4 order-md-1 col-lg-3 h-almost-full-md sticky-top-md" id="left_col">
<!-- The TOC is appended here -->
</div>
<div class="col-12 order-1 col-md-8 order-md-2 col-lg-7 order-lg-2 guide-section" id="middle_col">
<!-- start body -->
<div class="page_header">
<strong>IMPORTANT</strong>: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
<a href="../current/index.html">current release documentation</a>.
</div>
<div id="content">
<div class="breadcrumbs">
<span class="breadcrumb-link"><a href="/guide/">Elastic Docs</a></span>
<span class="chevron-right">›</span><span class="breadcrumb-link"><a href="index.html">Elasticsearch Guide [7.3]</a></span>
<span class="chevron-right">›</span><span class="breadcrumb-link"><a href="xpack-alerting.html">Alerting on cluster and index events</a></span>
<span class="chevron-right">›</span><span class="breadcrumb-link"><a href="actions.html">Actions</a></span>
</div>
<div class="navheader">
<span class="prev">
<a href="action-conditions.html">« Adding conditions to actions</a>
</span>
<span class="next">
<a href="actions-webhook.html">Webhook action »</a>
</span>
</div>
<div class="section xpack">
<div class="titlepage"><div><div>
<h2 class="title"><a id="actions-email"></a>Email action<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.3/x-pack/docs/en/watcher/actions/email.asciidoc">edit</a><a class="xpack_tag" href="/subscriptions"></a></h2>
</div></div></div>
<p>Use the <code class="literal">email</code> action to send email notifications. To send email, you must
<a class="xref" href="actions-email.html#configuring-email" title="Configuring email accounts">configure at least one email account</a> in
<code class="literal">elasticsearch.yml</code>.</p>
<p>Email notifications can be plain text or styled using HTML. You can include
information from the watch execution payload using <a class="xref" href="how-watcher-works.html#templates" title="Using templates">templates</a>
and attach the entire watch payload to the message.</p>
<p>See <a class="xref" href="actions-email.html#email-action-attributes" title="Email action attributes">Email action attributes</a> for the supported attributes. Any attributes that
are missing from the email action definition are looked up in the email
account configuration. The required attributes must either be set in the email
action definition or the account’s <code class="literal">email_defaults</code>.</p>
<div class="section">
<div class="titlepage"><div><div>
<h3 class="title"><a id="configuring-email-actions"></a>Configuring email actions<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.3/x-pack/docs/en/watcher/actions/email.asciidoc">edit</a></h3>
</div></div></div>
<p>You configure email actions in the <code class="literal">actions</code> array. Action-specific attributes
are specified using the <code class="literal">email</code> keyword.</p>
<p>For example, the following email action uses a template to include data from
the watch payload in the email body:</p>
<div class="pre_wrapper lang-js">
<pre class="programlisting prettyprint lang-js">"actions" : {
"send_email" : { <a id="CO500-1"></a><i class="conum" data-value="1"></i>
"email" : { <a id="CO500-2"></a><i class="conum" data-value="2"></i>
"to" : "[email protected]", <a id="CO500-3"></a><i class="conum" data-value="3"></i>
"subject" : "Watcher Notification", <a id="CO500-4"></a><i class="conum" data-value="4"></i>
"body" : "{{ctx.payload.hits.total.value}} error logs found" <a id="CO500-5"></a><i class="conum" data-value="5"></i>
}
}
}</pre>
</div>
<div class="calloutlist">
<table border="0" summary="Callout list">
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO500-1"><i class="conum" data-value="1"></i></a></p>
</td>
<td align="left" valign="top">
<p>The id of the action.</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO500-2"><i class="conum" data-value="2"></i></a></p>
</td>
<td align="left" valign="top">
<p>The action type is set to <code class="literal">email</code>.</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO500-3"><i class="conum" data-value="3"></i></a></p>
</td>
<td align="left" valign="top">
<p>One or more addresses to send the email to. Must be specified in the
action definition or in the email account configuration.</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO500-4"><i class="conum" data-value="4"></i></a></p>
</td>
<td align="left" valign="top">
<p>The subject of the email can contain static text and Mustache <a class="xref" href="how-watcher-works.html#templates" title="Using templates">templates</a>.</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO500-5"><i class="conum" data-value="5"></i></a></p>
</td>
<td align="left" valign="top">
<p>The body of the email can contain static text and Mustache <a class="xref" href="how-watcher-works.html#templates" title="Using templates">templates</a>. Must be specified in the action definition or in the email
account configuration.</p>
</td>
</tr>
</table>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div>
<h3 class="title"><a id="configuring-email-attachments"></a>Configuring email attachments<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.3/x-pack/docs/en/watcher/actions/email.asciidoc">edit</a></h3>
</div></div></div>
<p>You can attach the execution context payload or data from an any HTTP service to
the email notification. There is no limit on the number of attachments you can
configure.</p>
<p>To configure attachments, specify a name for the attached file and the type of
attachment: <code class="literal">data</code>, <code class="literal">http</code> or <code class="literal">reporting</code>. The <code class="literal">data</code> attachment type attaches the execution
context payload to the email message. The <code class="literal">http</code> attachment type enables
you to issue an HTTP request and attach the response to the email message. When
configuring the <code class="literal">http</code> attachment type, you must specify the request URL. The
<code class="literal">reporting</code> attachment type is a special type to include PDF rendered dashboards
from kibana. This type is consistently polling the kibana app if the dashboard
rendering is done, preventing long running HTTP connections, that are potentially
killed by firewalls or load balancers in-between.</p>
<div class="pre_wrapper lang-js">
<pre class="programlisting prettyprint lang-js">"actions" : {
"email_admin" : {
"email": {
"to": "John Doe <[email protected]>",
"attachments" : {
"my_image.png" : { <a id="CO501-1"></a><i class="conum" data-value="1"></i>
"http" : { <a id="CO501-2"></a><i class="conum" data-value="2"></i>
"content_type" : "image/png",
"request" : {
"url": "http://example.org/foo/my-image.png" <a id="CO501-3"></a><i class="conum" data-value="3"></i>
}
}
},
"dashboard.pdf" : {
"reporting" : {
"url": "http://example.org:5601/api/reporting/generate/dashboard/Error-Monitoring"
}
},
"data.yml" : {
"data" : {
"format" : "yaml" <a id="CO501-4"></a><i class="conum" data-value="4"></i>
}
}
}
}
}
}</pre>
</div>
<div class="calloutlist">
<table border="0" summary="Callout list">
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO501-1"><i class="conum" data-value="1"></i></a></p>
</td>
<td align="left" valign="top">
<p>The ID of the attachment, which is used as the file name in the email
attachment.</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO501-2"><i class="conum" data-value="2"></i></a></p>
</td>
<td align="left" valign="top">
<p>The type of the attachment and its specific configuration.</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO501-3"><i class="conum" data-value="3"></i></a></p>
</td>
<td align="left" valign="top">
<p>The URL from which to retrieve the attachment.</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO501-4"><i class="conum" data-value="4"></i></a></p>
</td>
<td align="left" valign="top">
<p>Data attachments default to JSON if you don’t specify the format.</p>
</td>
</tr>
</table>
</div>
<div class="table">
<p class="title"><strong>Table 96. <code class="literal">http</code> attachment type attributes</strong></p>
<div class="table-contents">
<table border="1" cellpadding="4px" summary="http attachment type attributes">
<colgroup>
<col class="col_1"/>
<col class="col_2"/>
</colgroup>
<thead>
<tr>
<th align="left" valign="top">Name</th>
<th align="left" valign="top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left" valign="top"><p><code class="literal">content_type</code></p></td>
<td align="left" valign="top"><p>Sets the content type for the email attachment. By default,
the content type is extracted from the response sent by the
HTTP service. You can explicitly specify the content type to
ensure that the type is set correctly in the email in case
the response does not specify the content type or it’s specified
incorrectly. Optional.</p></td>
</tr>
<tr>
<td align="left" valign="top"><p><code class="literal">inline</code></p></td>
<td align="left" valign="top"><p>Configures as an attachment to sent with disposition <code class="literal">inline</code>. This
allows the use of embedded images in HTML bodies, which are displayed
in certain email clients. Optional. Defaults to <code class="literal">false</code>.</p></td>
</tr>
<tr>
<td align="left" valign="top"><p><code class="literal">request</code></p></td>
<td align="left" valign="top"><p>Contains the HTTP request attributes. At a minimum, you must
specify the <code class="literal">url</code> attribute to configure the host and path to
the service endpoint. See <a class="xref" href="actions-webhook.html#webhook-action-attributes">Webhook action attributes</a> for
the full list of HTTP request attributes. Required.</p></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="table">
<p class="title"><strong>Table 97. <code class="literal">data</code> attachment type attributes</strong></p>
<div class="table-contents">
<table border="1" cellpadding="4px" summary="data attachment type attributes">
<colgroup>
<col class="col_1"/>
<col class="col_2"/>
</colgroup>
<thead>
<tr>
<th align="left" valign="top">Name</th>
<th align="left" valign="top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left" valign="top"><p><code class="literal">format</code></p></td>
<td align="left" valign="top"><p>Attaches the watch data, equivalent to specifying <code class="literal">attach_data</code>
in the watch configuration. Possible values are <code class="literal">json</code> or <code class="literal">yaml</code>.
Defaults to <code class="literal">json</code> if not specified.</p></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="table">
<p class="title"><strong>Table 98. <code class="literal">reporting</code> attachment type attributes</strong></p>
<div class="table-contents">
<table border="1" cellpadding="4px" summary="reporting attachment type attributes">
<colgroup>
<col class="col_1"/>
<col class="col_2"/>
</colgroup>
<thead>
<tr>
<th align="left" valign="top">Name</th>
<th align="left" valign="top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left" valign="top"><p><code class="literal">url</code></p></td>
<td align="left" valign="top"><p>The URL to trigger the dashboard creation</p></td>
</tr>
<tr>
<td align="left" valign="top"><p><code class="literal">inline</code></p></td>
<td align="left" valign="top"><p>Configures as an attachment to sent with disposition <code class="literal">inline</code>. This
allows the use of embedded images in HTML bodies, which are displayed
in certain email clients. Optional. Defaults to <code class="literal">false</code>.</p></td>
</tr>
<tr>
<td align="left" valign="top"><p><code class="literal">retries</code></p></td>
<td align="left" valign="top"><p>The reporting attachment type tries to poll regularly to receive the
created PDF. This configures the number of retries. Defaults to <code class="literal">40</code>.
The setting <code class="literal">xpack.notification.reporting.retries</code> can be configured
globally to change the default.</p></td>
</tr>
<tr>
<td align="left" valign="top"><p><code class="literal">interval</code></p></td>
<td align="left" valign="top"><p>The time to wait between two polling tries. Defaults to <code class="literal">15s</code> (this
means, by default watcher tries to download a dashboard for 10 minutes,
forty times fifteen seconds). The setting <code class="literal">xpack.notification.reporting.interval</code>
can be configured globally to change the default.</p></td>
</tr>
<tr>
<td align="left" valign="top"><p><code class="literal">request.auth</code></p></td>
<td align="left" valign="top"><p>Additional auth configuration for the request</p></td>
</tr>
<tr>
<td align="left" valign="top"><p><code class="literal">request.proxy</code></p></td>
<td align="left" valign="top"><p>Additional proxy configuration for the request</p></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div>
<h4 class="title"><a id="email-action-reports"></a>Attaching reports to an email<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.3/x-pack/docs/en/watcher/actions/email.asciidoc">edit</a></h4>
</div></div></div>
<p>You can use the <code class="literal">reporting</code> attachment type in an <code class="literal">email</code> action to automatically
generate a Kibana report and distribute it via email.</p>
<p>See <a href="/guide/en/kibana/7.3/automating-report-generation.html" class="ulink" target="_top">Automating report generation</a>.</p>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div>
<h3 class="title"><a id="email-action-attributes"></a>Email action attributes<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.3/x-pack/docs/en/watcher/actions/email.asciidoc">edit</a></h3>
</div></div></div>
<div class="informaltable">
<table border="1" cellpadding="4px">
<colgroup>
<col class="col_1"/>
<col class="col_2"/>
<col class="col_3"/>
<col class="col_4"/>
</colgroup>
<thead>
<tr>
<th align="left" valign="top">Name</th>
<th align="center" valign="top">Required</th>
<th align="left" valign="top">Default</th>
<th align="left" valign="top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left" valign="top"><p><code class="literal">account</code></p></td>
<td align="center" valign="top"><p>no</p></td>
<td align="left" valign="top"><p>the default account</p></td>
<td align="left" valign="top"><p>The <a class="xref" href="actions-email.html#configuring-email" title="Configuring email accounts">email account</a> to use to send the email.</p></td>
</tr>
<tr>
<td align="left" valign="top"><p><code class="literal">from</code></p></td>
<td align="center" valign="top"><p>no</p></td>
<td align="left" valign="top"><p>-</p></td>
<td align="left" valign="top"><p>The email <a class="xref" href="actions-email.html#email-address">address</a> from which the email
will be sent. The <code class="literal">from</code> field can contain Mustache
<a class="xref" href="how-watcher-works.html#templates" title="Using templates">templates</a> as long as it resolves to a
valid email address.</p></td>
</tr>
<tr>
<td align="left" valign="top"><p><code class="literal">to</code></p></td>
<td align="center" valign="top"><p>yes</p></td>
<td align="left" valign="top"><p>-</p></td>
<td align="left" valign="top"><p>The email <a class="xref" href="actions-email.html#email-address">addresses</a> of the <code class="literal">to</code> recipients.
The <code class="literal">to</code> field can contain Mustache <a class="xref" href="how-watcher-works.html#templates" title="Using templates">templates</a>
as long as it resolves to a valid email address.</p></td>
</tr>
<tr>
<td align="left" valign="top"><p><code class="literal">cc</code></p></td>
<td align="center" valign="top"><p>no</p></td>
<td align="left" valign="top"><p>-</p></td>
<td align="left" valign="top"><p>The email <a class="xref" href="actions-email.html#email-address">addresses</a> of the <code class="literal">cc</code> recipients.
The <code class="literal">cc</code> field can contain Mustache <a class="xref" href="how-watcher-works.html#templates" title="Using templates">templates</a>
as long as it resolves to a valid email address.</p></td>
</tr>
<tr>
<td align="left" valign="top"><p><code class="literal">bcc</code></p></td>
<td align="center" valign="top"><p>no</p></td>
<td align="left" valign="top"><p>-</p></td>
<td align="left" valign="top"><p>The email <a class="xref" href="actions-email.html#email-address">addresses</a> of the <code class="literal">bcc</code> recipients.
The <code class="literal">bcc</code> field can contain Mustache <a class="xref" href="how-watcher-works.html#templates" title="Using templates">templates</a>
as long as it resolves to a valid email address.</p></td>
</tr>
<tr>
<td align="left" valign="top"><p><code class="literal">reply_to</code></p></td>
<td align="center" valign="top"><p>no</p></td>
<td align="left" valign="top"><p>-</p></td>
<td align="left" valign="top"><p>The email <a class="xref" href="actions-email.html#email-address">addresses</a> that will be set on the
message’s <code class="literal">Reply-To</code> header. The <code class="literal">reply_to</code> field can contain
Mustache <a class="xref" href="how-watcher-works.html#templates" title="Using templates">templates</a> as long as it resolves to
a valid email address.</p></td>
</tr>
<tr>
<td align="left" valign="top"><p><code class="literal">subject</code></p></td>
<td align="center" valign="top"><p>no</p></td>
<td align="left" valign="top"><p>-</p></td>
<td align="left" valign="top"><p>The subject of the email. The subject can be static text or
contain Mustache <a class="xref" href="how-watcher-works.html#templates" title="Using templates">templates</a>.</p></td>
</tr>
<tr>
<td align="left" valign="top"><p><code class="literal">body</code></p></td>
<td align="center" valign="top"><p>no</p></td>
<td align="left" valign="top"><p>-</p></td>
<td align="left" valign="top"><p>The body of the email. When this field holds a string, it
will default to the text body of the email. Set as an object
to specify either the text or the html body or both (using
the fields below)</p></td>
</tr>
<tr>
<td align="left" valign="top"><p><code class="literal">body.text</code></p></td>
<td align="center" valign="top"><p>no</p></td>
<td align="left" valign="top"><p>-</p></td>
<td align="left" valign="top"><p>The plain text body of the email. The body can be static text
or contain Mustache <a class="xref" href="how-watcher-works.html#templates" title="Using templates">templates</a>.</p></td>
</tr>
<tr>
<td align="left" valign="top"><p><code class="literal">body.html</code></p></td>
<td align="center" valign="top"><p>no</p></td>
<td align="left" valign="top"><p>-</p></td>
<td align="left" valign="top"><p>The html body of the email. The body can be static text or
contain Mustache <a class="xref" href="how-watcher-works.html#templates" title="Using templates">templates</a>. This body will be
sanitized to remove dangerous content such as scripts. This
behavior can be disabled by setting
<code class="literal">xpack.notification.email.html.sanitization.enabled: false</code> in
<code class="literal">elasticsearch.yaml</code>.</p></td>
</tr>
<tr>
<td align="left" valign="top"><p><code class="literal">priority</code></p></td>
<td align="center" valign="top"><p>no</p></td>
<td align="left" valign="top"><p>-</p></td>
<td align="left" valign="top"><p>The priority of this email. Valid values are: <code class="literal">lowest</code>, <code class="literal">low</code>,
<code class="literal">normal</code>, <code class="literal">high</code> and <code class="literal">highest</code>. The priority can contain a
Mustache <a class="xref" href="how-watcher-works.html#templates" title="Using templates">template</a> as long as it resolves to
one of the valid values.</p></td>
</tr>
<tr>
<td align="left" valign="top"><p><code class="literal">attachments</code></p></td>
<td align="center" valign="top"><p>no</p></td>
<td align="left" valign="top"><p>-</p></td>
<td align="left" valign="top"><p>Attaches the watch payload (<code class="literal">data</code> attachment) or a file
retrieved from an HTTP service (<code class="literal">http</code> attachment) to the
email. For more information, see
<a class="xref" href="actions-email.html#configuring-email-attachments" title="Configuring email attachments">Configuring Email Attachments</a>.</p></td>
</tr>
<tr>
<td align="left" valign="top"><p><code class="literal">attach_data</code></p></td>
<td align="center" valign="top"><p>no</p></td>
<td align="left" valign="top"><p>false</p></td>
<td align="left" valign="top"><p>Indicates whether the watch execution data should be attached
to the email. You can specify a Boolean value or an object.
If <code class="literal">attach_data</code> is set to <code class="literal">true</code>, the data is attached as a
YAML file. This attribute is deprecated, use the <code class="literal">attachments</code>
attribute to add a <code class="literal">data</code> attachment to attach the watch payload.</p></td>
</tr>
<tr>
<td align="left" valign="top"><p><code class="literal">attach_data.format</code></p></td>
<td align="center" valign="top"><p>no</p></td>
<td align="left" valign="top"><p>yaml</p></td>
<td align="left" valign="top"><p>When <code class="literal">attach_data</code> is specified as an object, this field
controls the format of the attached data. The supported formats
are <code class="literal">json</code> and <code class="literal">yaml</code>. This attribute is deprecated, use the
<code class="literal">attachments</code> attribute to add a <code class="literal">data</code> attachment to attach
the watch payload.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="variablelist">
<a id="email-address"></a>
<dl class="variablelist">
<dt>
<span class="term">
Email Address
</span>
</dt>
<dd>
An email address can contain two possible parts—​the address itself and an
optional personal name as described in <a href="http://www.ietf.org/rfc/rfc822.txt" class="ulink" target="_top">RFC 822</a>.
The address can be represented either as a string of the form <code class="literal">[email protected]</code>
or <code class="literal">Personal Name <[email protected]></code>. You can also specify an email address as
an object that contains <code class="literal">name</code> and <code class="literal">address</code> fields.
</dd>
</dl>
</div>
<div class="variablelist">
<a id="address-list"></a>
<dl class="variablelist">
<dt>
<span class="term">
Address List
</span>
</dt>
<dd>
A list of addresses can be specified as a an
array: <code class="literal">[ 'Personal Name <[email protected]>', '[email protected]' ]</code>.
</dd>
</dl>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div>
<h3 class="title"><a id="configuring-email"></a>Configuring email accounts<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.3/x-pack/docs/en/watcher/actions/email.asciidoc">edit</a></h3>
</div></div></div>
<p>Watcher can send email using any SMTP email service. Email
messages can contain basic HTML tags. You can control which groups of tags are
allowed by <a class="xref" href="actions-email.html#email-html-sanitization" title="Configuring HTML sanitization options">Configuring HTML Sanitization Options</a>.</p>
<p>You configure the accounts Watcher can use to send email in the
<code class="literal">xpack.notification.email</code> namespace in <code class="literal">elasticsearch.yml</code>.</p>
<p>If your email account is configured to require two step verification, you need
to generate and use a unique App Password to send email from Watcher.
Authentication will fail if you use your primary password.</p>
<div class="important admon">
<div class="icon"></div>
<div class="admon_content">
<p>Currently, neither Watcher nor Shield provide a mechanism to encrypt
settings in <code class="literal">elasticsearch.yml</code>. Because the email account credentials appear
in plain text, you should limit access to <code class="literal">elasticsearch.yml</code> to the user that
you use to run Elasticsearch.</p>
</div>
</div>
<p><a id="email-profile"></a>Watcher provides three email profiles that control how MIME messages are
structured: <code class="literal">standard</code> (default), <code class="literal">gmail</code>, and <code class="literal">outlook</code>. These profiles
accommodate differences in how various email systems interpret the MIME
standard. If you are using Gmail or Outlook, we recommend using the
corresponding profile. Use the <code class="literal">standard</code> profile if you are using another
email system.</p>
<p>For more information about configuring Watcher to work with different email
systems, see:</p>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
<a class="xref" href="actions-email.html#gmail" title="Sending email from Gmail">Sending email from Gmail</a>
</li>
<li class="listitem">
<a class="xref" href="actions-email.html#outlook" title="Sending email from Outlook.com">Sending email from Outlook.com</a>
</li>
<li class="listitem">
<a class="xref" href="actions-email.html#exchange" title="Sending email from Microsoft Exchange">Sending email from Microsoft Exchange</a>
</li>
<li class="listitem">
<a class="xref" href="actions-email.html#amazon-ses" title="Sending email from Amazon SES (Simple Email Service)">Sending email from Amazon SES (Simple Email Service)</a>
</li>
</ul>
</div>
<p>If you configure multiple email accounts, you must either configure a default
account or specify which account the email should be sent with in the
<a class="xref" href="actions-email.html" title="Email action"><code class="literal">email</code></a> action.</p>
<div class="pre_wrapper lang-yaml">
<pre class="programlisting prettyprint lang-yaml">xpack.notification.email:
default_account: team1
account:
team1:
...
team2:
...</pre>
</div>
<h5><a id="gmail"></a>Sending email from Gmail<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.3/x-pack/docs/en/watcher/actions/email.asciidoc">edit</a></h5>
<p>Use the following email account settings to send email from the
<a href="https://mail.google.com" class="ulink" target="_top">Gmail</a> SMTP service:</p>
<div class="pre_wrapper lang-yaml">
<pre class="programlisting prettyprint lang-yaml">xpack.notification.email.account:
gmail_account:
profile: gmail
smtp:
auth: true
starttls.enable: true
host: smtp.gmail.com
port: 587
user: <username></pre>
</div>
<p>In order to store the account SMTP password, use the keystore command
(see <a href="/guide/en/elasticsearch/reference/7.3/secure-settings.html" class="ulink" target="_top">secure settings</a>)</p>
<div class="pre_wrapper lang-yaml">
<pre class="programlisting prettyprint lang-yaml">bin/elasticsearch-keystore add xpack.notification.email.account.gmail_account.smtp.secure_password</pre>
</div>
<p>If you get an authentication error that indicates that you need to continue the
sign-in process from a web browser when Watcher attempts to send email, you need
to configure Gmail to <a href="https://support.google.com/accounts/answer/6010255?hl=en" class="ulink" target="_top">Allow
Less Secure Apps to access your account</a>.</p>
<p>If two-step verification is enabled for your account, you must generate and use
a unique App Password to send email from Watcher. See
<a href="https://support.google.com/accounts/answer/185833?hl=en" class="ulink" target="_top">Sign in using App Passwords</a>
for more information.</p>
<h5><a id="outlook"></a>Sending email from Outlook.com<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.3/x-pack/docs/en/watcher/actions/email.asciidoc">edit</a></h5>
<p>Use the following email account settings to send email action from the
<a href="https://www.outlook.com/" class="ulink" target="_top">Outlook.com</a> SMTP service:</p>
<div class="pre_wrapper lang-yaml">
<pre class="programlisting prettyprint lang-yaml">xpack.notification.email.account:
outlook_account:
profile: outlook
smtp:
auth: true
starttls.enable: true
host: smtp-mail.outlook.com
port: 587
user: <email.address></pre>
</div>
<p>In order to store the account SMTP password, use the keystore command
(see <a href="/guide/en/elasticsearch/reference/7.3/secure-settings.html" class="ulink" target="_top">secure settings</a>)</p>
<div class="pre_wrapper lang-yaml">
<pre class="programlisting prettyprint lang-yaml">bin/elasticsearch-keystore add xpack.notification.email.account.outlook_account.smtp.secure_password</pre>
</div>
<p>When sending emails, you have to provide a from address, either a default one
in your account configuration or as part of the email action in the watch.</p>
<div class="note admon">
<div class="icon"></div>
<div class="admon_content">
<p>You need to use a unique App Password if two-step verification is enabled.
See <a href="http://windows.microsoft.com/en-us/windows/app-passwords-two-step-verification" class="ulink" target="_top">App
passwords and two-step verification</a> for more information.</p>
</div>
</div>
<h5><a id="amazon-ses"></a>Sending email from Amazon SES (Simple Email Service)<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.3/x-pack/docs/en/watcher/actions/email.asciidoc">edit</a></h5>
<p>Use the following email account settings to send email from the
<a href="http://aws.amazon.com/ses" class="ulink" target="_top">Amazon Simple Email Service</a> (SES) SMTP service:</p>
<div class="pre_wrapper lang-yaml">
<pre class="programlisting prettyprint lang-yaml">xpack.notification.email.account:
ses_account:
smtp:
auth: true
starttls.enable: true
starttls.required: true
host: email-smtp.us-east-1.amazonaws.com <a id="CO502-1"></a><i class="conum" data-value="1"></i>
port: 587
user: <username></pre>
</div>
<div class="calloutlist">
<table border="0" summary="Callout list">
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO502-1"><i class="conum" data-value="1"></i></a></p>
</td>
<td align="left" valign="top">
<p><code class="literal">smtp.host</code> varies depending on the region</p>
</td>
</tr>
</table>
</div>
<p>In order to store the account SMTP password, use the keystore command
(see <a href="/guide/en/elasticsearch/reference/7.3/secure-settings.html" class="ulink" target="_top">secure settings</a>)</p>
<div class="pre_wrapper lang-yaml">
<pre class="programlisting prettyprint lang-yaml">bin/elasticsearch-keystore add xpack.notification.email.account.ses_account.smtp.secure_password</pre>
</div>
<div class="note admon">
<div class="icon"></div>
<div class="admon_content">
<p>You need to use your Amazon SES SMTP credentials to send email through
Amazon SES. For more information, see
<a href="http://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-credentials.html" class="ulink" target="_top">Obtaining
Your Amazon SES SMTP Credentials</a>. You might also need to verify
<a href="https://docs.aws.amazon.com/ses/latest/DeveloperGuide/verify-email-addresses.html" class="ulink" target="_top">your email address</a>
or <a href="https://docs.aws.amazon.com/ses/latest/DeveloperGuide/verify-domains.html" class="ulink" target="_top">your whole domain</a>
at AWS.</p>
</div>
</div>
<h5><a id="exchange"></a>Sending email from Microsoft Exchange<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.3/x-pack/docs/en/watcher/actions/email.asciidoc">edit</a></h5>
<p>Use the following email account settings to send email action from Microsoft
Exchange:</p>
<div class="pre_wrapper lang-yaml">
<pre class="programlisting prettyprint lang-yaml">xpack.notification.email.account:
exchange_account:
profile: outlook
email_defaults:
from: <email address of service account> <a id="CO503-1"></a><i class="conum" data-value="1"></i>
smtp:
auth: true
starttls.enable: true
host: <your exchange server>
port: 587
user: <email address of service account> <a id="CO503-2"></a><i class="conum" data-value="2"></i></pre>
</div>
<div class="calloutlist">
<table border="0" summary="Callout list">
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO503-1"><i class="conum" data-value="1"></i></a></p>
</td>
<td align="left" valign="top">
<p>Some organizations configure Exchange to validate that the <code class="literal">from</code> field is a
valid local email account.</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO503-2"><i class="conum" data-value="2"></i></a></p>
</td>
<td align="left" valign="top">
<p>Many organizations support use of your email address as your username, though
it is a good idea to check with your system administrator if you receive
authentication-related failures.</p>
</td>
</tr>
</table>
</div>
<p>In order to store the account SMTP password, use the keystore command
(see <a href="/guide/en/elasticsearch/reference/7.3/secure-settings.html" class="ulink" target="_top">secure settings</a>)</p>
<div class="pre_wrapper lang-yaml">
<pre class="programlisting prettyprint lang-yaml">bin/elasticsearch-keystore add xpack.notification.email.account.exchange_account.smtp.secure_password</pre>
</div>
<h5><a id="email-html-sanitization"></a>Configuring HTML sanitization options<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.3/x-pack/docs/en/watcher/actions/email.asciidoc">edit</a></h5>
<p>The <code class="literal">email</code> action supports sending messages with an HTML body. However, for
security reasons, Watcher <a href="https://en.wikipedia.org/wiki/HTML_sanitization" class="ulink" target="_top">sanitizes</a>
the HTML.</p>
<p>You can control which HTML features are allowed or disallowed by configuring the
<code class="literal">xpack.notification.email.html.sanitization.allow</code> and
<code class="literal">xpack.notification.email.html.sanitization.disallow</code> settings in
<code class="literal">elasticsearch.yml</code>. You can specify individual HTML elements and
<a href="/guide/en/elasticsearch/reference/7.3/notification-settings.html#html-feature-groups" class="ulink" target="_top">HTML feature groups</a>. By default, Watcher allows the following
features: <code class="literal">body</code>, <code class="literal">head</code>, <code class="literal">_tables</code>, <code class="literal">_links</code>, <code class="literal">_blocks</code>, <code class="literal">_formatting</code> and
<code class="literal">img:embedded</code>.</p>
<p>For example, the following settings allow the HTML to contain tables and block
elements, but disallow <code class="literal"><h4></code>, <code class="literal"><h5></code> and <code class="literal"><h6></code> tags.</p>
<div class="pre_wrapper lang-yaml">
<pre class="programlisting prettyprint lang-yaml">xpack.notification.email.html.sanitization:
allow: _tables, _blocks
disallow: h4, h5, h6</pre>
</div>
<p>To disable sanitization entirely, add the following setting to
<code class="literal">elasticsearch.yml</code>:</p>
<div class="pre_wrapper lang-yaml">
<pre class="programlisting prettyprint lang-yaml">xpack.notification.email.html.sanitization.enabled: false</pre>
</div>
</div>
</div>
<div class="navfooter">
<span class="prev">
<a href="action-conditions.html">« Adding conditions to actions</a>
</span>
<span class="next">
<a href="actions-webhook.html">Webhook action »</a>
</span>
</div>
</div>
<!-- end body -->
</div>
<div class="col-12 order-3 col-lg-2 order-lg-3 h-almost-full-lg sticky-top-lg" id="right_col">
<div id="sticky_content">
<!-- The OTP is appended here -->
<div class="row">
<div class="col-0 col-md-4 col-lg-0" id="bottom_left_col"></div>
<div class="col-12 col-md-8 col-lg-12">
<div id="rtpcontainer">
<div class="mktg-promo" id="most-popular">
<p class="aside-heading">Most Popular</p>
<div class="pb-2">
<p class="media-type">Video</p>
<a href="https://www.elastic.co/webinars/getting-started-elasticsearch?page=docs&placement=top-video">
<p class="mb-0">Get Started with Elasticsearch</p>
</a>
</div>
<div class="pb-2">
<p class="media-type">Video</p>
<a href="https://www.elastic.co/webinars/getting-started-kibana?page=docs&placement=top-video">
<p class="mb-0">Intro to Kibana</p>
</a>
</div>
<div class="pb-2">
<p class="media-type">Video</p>
<a href="https://www.elastic.co/webinars/introduction-elk-stack?page=docs&placement=top-video">
<p class="mb-0">ELK for Logs & Metrics</p>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
</div>
<div id='elastic-footer'></div>
<script src='https://www.elastic.co/elastic-footer.js'></script>
<!-- Footer Section end-->
</section>
</div>
<script src="/guide/static/jquery.js"></script>
<script type="text/javascript" src="/guide/static/docs.js"></script>
<script type="text/javascript">
window.initial_state = {}</script>
</body>
</html>