# Logstash Email error : email - Something happen while delivering an email {:exception=\>#\<Net::SMTPAuthenticationError: Must issue a STARTTLS command first

**URL:** <https://discuss.elastic.co/t/logstash-email-error-email-something-happen-while-delivering-an-email-exception-net-must-issue-a-starttls-command-first/191861>\
**Category:** Logstash\
**Created:** [July 23, 2019, 3:47pm UTC](https://discuss.elastic.co/t/logstash-email-error-email-something-happen-while-delivering-an-email-exception-net-must-issue-a-starttls-command-first/191861 "2019-07-23T15:47:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![irobot678](https://avatars.discourse-cdn.com/v4/letter/i/54ee81/32.png) [@irobot678](https://discuss.elastic.co/u/irobot678)\
**Post date:** [July 23, 2019, 3:47pm UTC](https://discuss.elastic.co/t/logstash-email-error-email-something-happen-while-delivering-an-email-exception-net-must-issue-a-starttls-command-first/191861/1 "2019-07-23T15:47:41Z")

</div>

Hi ,

I am using elk stack of version 7.1.1 + X-pack on unbuntu 14.04 .

i want to trigger a alert whenever the message contains "Exception " keyword in it.

logstash.yml

```
input {
  file {
    path => "/home/a.log"
    start_position => "beginning"
    codec => multiline {
      pattern => "^%{TIMESTAMP_ISO8601}"
      negate => true
      what => "previous"
     }	
  }
}
filter {

grok {
  match => ["message","[%{LOGLEVEL:log-level}\*%{GREEDYDATA:messagedata}"] 	
	
	}
}
output {
  elasticsearch { 
	hosts => ["localhost:9200"] 
	user => elastic
        password => mypassword 
}
  stdout { codec => rubydebug }

if "Exception" in [message]{
email {
	to => "v888888888@gmail.com"
	from => "vasadssfrdefd1997@gmail.com"
	subject => "Ignore (2-node envinorment test Alerts)"
	body => "log-message: %{message} \nLog file: %{path}"       
	codec => "plain"
	address => "smtp.gmail.com"
	port => "25"
	       
	}
    }    

}

```

I am able to write logs into es and console but the email alerts are not working i'm seeing a rare error when i print my logs on console along

please look into the following output on console.

```
         "log-level" => "debug",
        "@timestamp" => 2019-07-23T15:32:07.651Z,
           "message" => "2019-07-14 09:57:12:001*[debug]*nodejs*req-res-service*sendRequest*990009621098683*88fdad4c-93c3-4e47-88b5-bf9d894863aa*error while sending request.Error: NotLeaderForPartition",
          "@version" => "1",
              "path" => "/home/a.log",
              "host" => "desktop"
}

 [ERROR] 2019-07-23 21:02:09.601 [[main]>worker0] email - Something happen while delivering an email {:exception=>#<Net::SMTPAuthenticationError: 530 5.7.0 Must issue a STARTTLS command first. f6sm45399840pga.50 - gsmtp}

```

Please help me solve it.

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [July 23, 2019, 4:10pm UTC](https://discuss.elastic.co/t/logstash-email-error-email-something-happen-while-delivering-an-email-exception-net-must-issue-a-starttls-command-first/191861/2 "2019-07-23T16:10:14Z")

</div>

> [@irobot678](#):
>
> address =\> "[smtp.gmail.com](http://smtp.gmail.com)"

If you are really going through gmail then you should be using port 587, [use\_tls](https://www.elastic.co/guide/en/logstash/current/plugins-outputs-email.html#plugins-outputs-email-use_tls) should be true, and you will need a valid username and password for a Google account.

---

<div class="post-metadata">

**Author:** ![irobot678](https://avatars.discourse-cdn.com/v4/letter/i/54ee81/32.png) [@irobot678](https://discuss.elastic.co/u/irobot678)\
**Post date:** [July 24, 2019, 11:40am UTC](https://discuss.elastic.co/t/logstash-email-error-email-something-happen-while-delivering-an-email-exception-net-must-issue-a-starttls-command-first/191861/3 "2019-07-24T11:40:48Z")

</div>

Thanks @Badger.

Your solution solved my issue. 🙂

---

<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:** [August 21, 2019, 11:43am UTC](https://discuss.elastic.co/t/logstash-email-error-email-something-happen-while-delivering-an-email-exception-net-must-issue-a-starttls-command-first/191861/4 "2019-08-21T11:43:54Z")

</div>

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