# Mail using Postfix and Alerting not working

**URL:** <https://discuss.elastic.co/t/mail-using-postfix-and-alerting-not-working/166375>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [January 30, 2019, 2:23pm UTC](https://discuss.elastic.co/t/mail-using-postfix-and-alerting-not-working/166375 "2019-01-30T14:23:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Miguel\_Plazas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/miguel_plazas/32/40038_2.png) [@Miguel\_Plazas](https://discuss.elastic.co/u/Miguel_Plazas)\
**Post date:** [January 30, 2019, 2:23pm UTC](https://discuss.elastic.co/t/mail-using-postfix-and-alerting-not-working/166375/1 "2019-01-30T14:23:49Z")

</div>

Hi, currently i'm trying to send a mail using postfix on my own localhost, where i have instaled elastic. Currently this is **main.cf** from _/etc/postfix/main.cf_

```
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
# Debian specific: Specifying a file name will cause the first
# line of that file to be used as the name. The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=no
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = familia-plazas
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = $myhostname, familia-plazas, localhost.localdomain, , localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 192.168.1.0/24
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all

```

However, when I execute this command:

`"echo "This is the body of the email" | mail -s "This is the subject line" ambigus9@gmail.com"`

But i didn't get any mail 😭

By the other hand, I just putting this whatcher:

```
PUT _xpack/watcher/watch/test
{
  "trigger": {
    "schedule": {
      "interval": "1m"
    }
  },
  "input": {
    "search": {
      "request": {
        "indices": "heartbeat-*",
        "types": "doc",
        "body": {
          "query": {
            "bool": {
              "should": [
                {
                  "wildcard": {
                    "http.url": "*localhost*"
                  }
                }
              ]
            }
          },
          "sort": [
            {
              "@timestamp": {
                "order": "desc"
              }
            }
          ],
          "size": 1
        }
      }
    }
  },
  "condition": {
    "compare": {
      "ctx.payload.hits.hits.0._source.monitor.status": {
        "eq": "down"
      }
    }
  },
  "actions": {
    "send_email": {
      "throttle_period": "15m",
      "email": {
        "from": "root@elastic01",
        "to": "ambigus9@gmail.com",
        "subject": "ALERT APACHE: Server Down",
        "body": """
Se han detectado eventos de una posible caida del servidor {{ctx.payload.hits.hits.0._source.http.url}} 
 - Hora del evento: {{ctx.payload.hits.hits.0._source.@timestamp}} 

"""
      }
    }
  }
}

```

And, when i make the post:

`POST _xpack/watcher/watch/test/_execute`

Here is part the answer that i getting:

```
      "condition" : {
        "type" : "compare",
        "status" : "success",
        "met" : true,
        "compare" : {
          "resolved_values" : {
            "ctx.payload.hits.hits.0._source.monitor.status" : "down"
          }
        }
      },
      "actions" : [
        {
          "id" : "send_email",
          "type" : "email",
          "status" : "success",
          "email" : {
            "account" : "company_account",
            "message" : {
              "id" : "send_email_test_47760a2d-3dea-4de2-b612-ca357e5cb975-2019-01-30T01:11:24.149Z",
              "from" : "root@elastic01",
              "sent_date" : "2019-01-30T01:11:24.173Z",
              "to" : [
                "ambigus9@gmail.com"
              ],
              "subject" : "ALERT APACHE: Server Down",
              "body" : {
                "text" : "Se han detectado eventos de una posible caida del servidor http://localhost:80 \n - Hora del evento: 2019-01-30T01:11:12.347Z "
              }
            }
          }
        }
      ]
    },
    "messages" : []
  }
}

```

Any possible solution? Thanks!!

---

<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:** [February 27, 2019, 2:23pm UTC](https://discuss.elastic.co/t/mail-using-postfix-and-alerting-not-working/166375/2 "2019-02-27T14:23:49Z")

</div>

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