# Error sending mail with attachment using x-pack

**URL:** <https://discuss.elastic.co/t/error-sending-mail-with-attachment-using-x-pack/97568>\
**Category:** Elasticsearch\
**Created:** [August 18, 2017, 11:13am UTC](https://discuss.elastic.co/t/error-sending-mail-with-attachment-using-x-pack/97568 "2017-08-18T11:13:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Prashant\_Agrawal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prashant_agrawal/32/74982_2.png) [@Prashant\_Agrawal](https://discuss.elastic.co/u/Prashant_Agrawal)\
**Post date:** [August 18, 2017, 11:13am UTC](https://discuss.elastic.co/t/error-sending-mail-with-attachment-using-x-pack/97568/1 "2017-08-18T11:13:41Z")

</div>

I am using x-pack to configure auto reporting of dashboard , for that I have created a watch and while executing the same I am getting below error:

> "reason": "Watch[test] reporting[dashboard.pdf] Error response when trying to trigger reporting generation host[10.2.85.1], port[8150] method[POST], path[/api/reporting/generate/dashboard/f24aee00-80f1-11e7-8b6c-07b2c9e1ab5a], status[401]"

My config is as below ;

> ```
> {
> "trigger": {
> "schedule": {
> "interval": "1m"
> }
> },
> "input": {
> "none": {}
> },
> "condition": {
> "always": {}
> },
> "actions": {
> "send_email": {
> "email": {
> "profile": "standard",
> "attachments": {
> "dashboard.pdf": {
> "reporting": {
> "url": "http://10.2.85.1:8150/api/reporting/generate/dashboard/f24aee00-80f1-11e7-8b6c-07b2c9e1ab5a"
> }
> }
> },
> "from": "test@abc.com",
> "to": [
> "test@gmail.com",
> ],
> "subject": "Error Monitoring Report",
> "body": {
> "text": "Report Generated"
> }
> }
> }
> }
> }
> 
> ```

will be good if someone can help for same.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 18, 2017, 12:56pm UTC](https://discuss.elastic.co/t/error-sending-mail-with-attachment-using-x-pack/97568/2 "2017-08-18T12:56:59Z")

</div>

the HTTP status 401 indicates you might be missing required authentication data.

---

<div class="post-metadata">

**Author:** ![Prashant\_Agrawal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prashant_agrawal/32/74982_2.png) [@Prashant\_Agrawal](https://discuss.elastic.co/u/Prashant_Agrawal)\
**Post date:** [August 18, 2017, 1:50pm UTC](https://discuss.elastic.co/t/error-sending-mail-with-attachment-using-x-pack/97568/3 "2017-08-18T13:50:49Z")

</div>

Thanks @spinscale , I think I missed

> ```
> "auth": {
> "basic": {
> "username": "prashant"
> }
> }
> 
> ```

after adding the same it worked.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 15, 2017, 1:50pm UTC](https://discuss.elastic.co/t/error-sending-mail-with-attachment-using-x-pack/97568/4 "2017-09-15T13:50:55Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
