# From logstash i need to send email to gmail

**URL:** <https://discuss.elastic.co/t/from-logstash-i-need-to-send-email-to-gmail/99419>\
**Category:** Logstash\
**Created:** [September 5, 2017, 12:11pm UTC](https://discuss.elastic.co/t/from-logstash-i-need-to-send-email-to-gmail/99419 "2017-09-05T12:11:17Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![suganth](https://avatars.discourse-cdn.com/v4/letter/s/f17d59/32.png) [@suganth](https://discuss.elastic.co/u/suganth)\
**Post date:** [September 5, 2017, 12:11pm UTC](https://discuss.elastic.co/t/from-logstash-i-need-to-send-email-to-gmail/99419/1 "2017-09-05T12:11:17Z")

</div>

Hi,

I have to send the email from my logstash. my configuration is , What are the prerequisites to achieve the requirement apart from the below configuration.

email {

```
	to => 'xyz@gmail.com'
	via => 'smtp'
	address => 'smtp.gmail.com'
	from => 'xyz@gmail.com'
	subject => 'Alert - %{title}'
	body => "Tags: %{tags}\\n\\Content:\\n%{message}"
	port => 25
	use_tls => false

```

}

For your reference in my logstash machine doesn't have mail server,  
when i execute the below command in my machine it doent connect the gmail smtp  
command is telnet "[smtp.gmail.com](http://smtp.gmail.com) 587"

error is "Could not open connection to the host, on port 587: Connect failed"

Thanks in Advance,  
Suganth a

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [September 5, 2017, 1:20pm UTC](https://discuss.elastic.co/t/from-logstash-i-need-to-send-email-to-gmail/99419/2 "2017-09-05T13:20:22Z")

</div>

Well, if you can't connect to [smtp.gmail.com:587](http://smtp.gmail.com:587) then you can't send email via Gmail. IIRC the email output uses STARTTLS rather than SMTPS, otherwise SSL over port 465 would've been an option.

---

<div class="post-metadata">

**Author:** ![suganth](https://avatars.discourse-cdn.com/v4/letter/s/f17d59/32.png) [@suganth](https://discuss.elastic.co/u/suganth)\
**Post date:** [September 6, 2017, 4:23am UTC](https://discuss.elastic.co/t/from-logstash-i-need-to-send-email-to-gmail/99419/3 "2017-09-06T04:23:03Z")

</div>

Thanks Magnusbaeck, With the help of network admin I am receiving the following response for the command "telnet [smtp.gmail.com](http://smtp.gmail.com) 587"  
Response is  
**"220 [smtp.gmail.com](http://smtp.gmail.com) ESMTP 77sm680281pfz.47 - gsmtp"**

Than i tried to send a mail but i got the error as  
**"[logstash.outputs.email] Something happen while delivering an email {:exception=\>#\<Net::SMTPAuthenticationError: 530-5.5.1 Authentication Required. Learn more at"** Could you please help me to solve this.

---

<div class="post-metadata">

**Author:** ![suganth](https://avatars.discourse-cdn.com/v4/letter/s/f17d59/32.png) [@suganth](https://discuss.elastic.co/u/suganth)\
**Post date:** [September 6, 2017, 4:55am UTC](https://discuss.elastic.co/t/from-logstash-i-need-to-send-email-to-gmail/99419/4 "2017-09-06T04:55:11Z")

</div>

Thanks Magnus, Now it worked for me but the error message is not going as email.. instead the IF condition alone going as a body in my mail my configuration is  
\*\*  
if "Eligibility Overruled.." in [message] {  
email {

```
	to => 'xyz@gmail.com'
	codec => "plain"
	debug => 'true'
	via => 'smtp'
	address => 'smtp.gmail.com'
	username => 'xyz@gmail.com'
	password => 'xyz'
	subject => 'Alert - %{title}'
	body => '%{message}'
	port => 25
	use_tls => true

```

}  
}\*\*

From the above cofiguration i can receive the message in my mail as **Eligibility Overruled..** but i need full error message.

Thanks,  
Suganth A

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [September 6, 2017, 5:19am UTC](https://discuss.elastic.co/t/from-logstash-i-need-to-send-email-to-gmail/99419/5 "2017-09-06T05:19:33Z")

</div>

I don't quite understand. The configuration above should give you an email with the full text of the `message` field. Is that not enough? If so, where is the rest of the information you want?

---

<div class="post-metadata">

**Author:** ![suganth](https://avatars.discourse-cdn.com/v4/letter/s/f17d59/32.png) [@suganth](https://discuss.elastic.co/u/suganth)\
**Post date:** [September 6, 2017, 5:22am UTC](https://discuss.elastic.co/t/from-logstash-i-need-to-send-email-to-gmail/99419/6 "2017-09-06T05:22:19Z")

</div>

No Magnus its not giving the full text if message field instead it giving the text what i have used for IF condition that is giving as message, based on the above configuration am receiving the message as **Eligibility Overruled…**

Thanks,  
Suganth A

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [September 6, 2017, 5:29am UTC](https://discuss.elastic.co/t/from-logstash-i-need-to-send-email-to-gmail/99419/7 "2017-09-06T05:29:16Z")

</div>

I find that very hard to believe. If you change the condition to be `if "Eligibility Over" in [message]`, does the email contents change accordingly?

---

<div class="post-metadata">

**Author:** ![suganth](https://avatars.discourse-cdn.com/v4/letter/s/f17d59/32.png) [@suganth](https://discuss.elastic.co/u/suganth)\
**Post date:** [September 6, 2017, 8:08am UTC](https://discuss.elastic.co/t/from-logstash-i-need-to-send-email-to-gmail/99419/8 "2017-09-06T08:08:19Z")

</div>

Its my mistake magnus, in the message it gets the actual error message alone and sending the error , I didn't understand properly, Thanks boss.

---

<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:** [October 4, 2017, 8:08am UTC](https://discuss.elastic.co/t/from-logstash-i-need-to-send-email-to-gmail/99419/9 "2017-10-04T08:08:33Z")

</div>

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