# ERROR logstash.outputs.email

**URL:** <https://discuss.elastic.co/t/error-logstash-outputs-email/296729>\
**Category:** Logstash\
**Created:** [February 9, 2022, 1:21pm UTC](https://discuss.elastic.co/t/error-logstash-outputs-email/296729 "2022-02-09T13:21:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![alex\_vermex](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alex_vermex/32/101267_2.png) [@alex\_vermex](https://discuss.elastic.co/u/alex_vermex)\
**Post date:** [February 9, 2022, 1:21pm UTC](https://discuss.elastic.co/t/error-logstash-outputs-email/296729/1 "2022-02-09T13:21:47Z")

</div>

Hi,  
My code:

```auto
email {
    to => "za@gmail.com"
    via => 'smtp'
	address => 'smtp.gmail.com'
	from => 'john@gmail.com'
    authentication => "plain"
    username => "john@gmail.com"
	password => "john123"
	subject => 'Alert '
	body => "Test message test...."
	port => 587
	use_tls => true
    }

```

and i got this error:

```auto
Something happen while delivering an email {:exception=>#<Net::SMTPAuthenticationError: 535-5.7.8 Username and Password not accepted.

```

what Username and Password should i use i dont understand!

Any help would be sincerely appreciate!  
Thanks.

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [February 9, 2022, 3:24pm UTC](https://discuss.elastic.co/t/error-logstash-outputs-email/296729/2 "2022-02-09T15:24:02Z")

</div>

The `email` output needs to connect to a SMTP server to send the e-mails, since you didn't configure the `domain` option in the output, it is connecting to `localhost`.

Since you want to send the e-mail as your gmail user, you need to use the Gmail smtp server, which I think is `smtp.gmail.com` in the `domain` option, but If I'm not wrong you will need to change somethings in your gmail account to allow that, I think you will need to crea an app password.

This is not a Logstash issue, you need to check in Gmail/Google documentation how to send e-mails using their SMTP.

---

<div class="post-metadata">

**Author:** ![alex\_vermex](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alex_vermex/32/101267_2.png) [@alex\_vermex](https://discuss.elastic.co/u/alex_vermex)\
**Post date:** [February 9, 2022, 3:51pm UTC](https://discuss.elastic.co/t/error-logstash-outputs-email/296729/3 "2022-02-09T15:51:03Z")

</div>

Thanks Leandro, it works  
another question please my filter bloc:

```auto
filter {
    if !("Exception" in [message] or "EXCEPTION" in [message]) {drop{}}
}

```

it gives me this output in mail:

 ![l](https://us1.discourse-cdn.com/elastic/original/3X/e/3/e3f44c3a6979133efb8e61907ab8c489f8319292.png)

I just want to ask you if i can regroupe all this mails in one mail contains all of them or somthing like this cuz imagine that i have more than 40 exception for example it will send me a 40 emails ?!

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:** [March 9, 2022, 3:51pm UTC](https://discuss.elastic.co/t/error-logstash-outputs-email/296729/4 "2022-03-09T15:51:59Z")

</div>

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