# Logstash Email Output Plugin not working

**URL:** <https://discuss.elastic.co/t/logstash-email-output-plugin-not-working/114964>\
**Category:** Logstash\
**Created:** [January 10, 2018, 9:21pm UTC](https://discuss.elastic.co/t/logstash-email-output-plugin-not-working/114964 "2018-01-10T21:21:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![yinzhi7](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yinzhi7/32/26447_2.png) [@yinzhi7](https://discuss.elastic.co/u/yinzhi7)\
**Post date:** [January 10, 2018, 9:21pm UTC](https://discuss.elastic.co/t/logstash-email-output-plugin-not-working/114964/1 "2018-01-10T21:21:38Z")

</div>

Here is my email setting  
email {  
to =\> "lovework@happywork.com"  
from =\> "lovework@happywork.com"  
subject =\> "Alert"  
body =\> "Content:\n%{message}"  
domain =\> "[outlook.corp3.happywork.com](http://outlook.corp3.happywork.com)"  
port =\> 25  
}

Domain is default to 'localhost' thus i overrode it to our mail server.

But very oddly, the error log says below:  
-10T16:03:03,851][INFO][org.logstash.beats.BeatsHandler] [local: 0.0.0.0:5044, remote: 10.4.32.91:50234] Exception: An existing connection was forcibly closed by the remote host  
[2018-01-10T16:03:46,012][ERROR][logstash.outputs.email] Something happen while delivering an email {:exception=\>#\<Errno::ECONNREFUSED: Connection refused - connect(2) for "localhost" port 25\>}  
[2018-01-10T16:03:47,163][ERROR][logstash.outputs.email] Something happen while delivering an email {:exception=\>#\<Errno::ECONNREFUSED: Connection refused - connect(2) for "localhost" port 25\>}

---

<div class="post-metadata">

**Author:** ![yinzhi7](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yinzhi7/32/26447_2.png) [@yinzhi7](https://discuss.elastic.co/u/yinzhi7)\
**Post date:** [January 10, 2018, 9:22pm UTC](https://discuss.elastic.co/t/logstash-email-output-plugin-not-working/114964/2 "2018-01-10T21:22:58Z")

</div>

I don't quite understand is why it still tries to connect to localhost while i have changed it to  
"[outlook.corp3.happywork.com](http://outlook.corp3.happywork.com)"

Thanks!

---

<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:** [January 10, 2018, 9:31pm UTC](https://discuss.elastic.co/t/logstash-email-output-plugin-not-working/114964/3 "2018-01-10T21:31:17Z")

</div>

domain is what is sent on the EHLO, it should match where you are sending mail from, not what you are connecting to. address is what it connects to. Can you try adding this?

`address => "outlook.corp3.happywork.com"`

---

<div class="post-metadata">

**Author:** ![yinzhi7](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yinzhi7/32/26447_2.png) [@yinzhi7](https://discuss.elastic.co/u/yinzhi7)\
**Post date:** [January 11, 2018, 7:42pm UTC](https://discuss.elastic.co/t/logstash-email-output-plugin-not-working/114964/4 "2018-01-11T19:42:26Z")

</div>

It works! Sorry for not reading the doc careful enough. Thank!!

---

<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 8, 2018, 7:50pm UTC](https://discuss.elastic.co/t/logstash-email-output-plugin-not-working/114964/5 "2018-02-08T19:50:51Z")

</div>

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