This certainly suggests that nobody's listening on localhost:25. Is Postfix perhaps only listening on the IPv6 interface an Logstash only support IPv4? That could explain why "telnet localhost 25" works and seemingly does so by connecting to ::1.
I am able to send and receive email from terminal, though:
And is Postfix actually listening on 127.0.0.1:25? Does "telnet 127.0.0.1 25" work? Does Wireshark reveal anything about what's going on? Could a firewall be blocking the access?
I also tried to send email this way and I was able to receive it:
mail -s "subject" recipient@email.com <email_body>
And this way:
sendmail EMAILADDRESS
FROM: FROMADDRESS
SUBJECT: hello world
this is a test email
.
When I tried to send email via sendmail I got this errors:
11:56:31.514 [[main]>worker0] ERROR logstash.outputs.email - Something happen while delivering an email {:exception=>#<IOError: Cannot run program "/usr/sbin/sendmail" (in directory "/"): error=2, No such file or directory>}
11:56:31.590 [[main]>worker0] ERROR logstash.outputs.email - Something happen while delivering an email {:exception=>#<IOError: Cannot run program "/usr/sbin/sendmail" (in directory "/"): error=2, No such file or directory>}
It looks like it happened because I am running Logstash in Docker.
Though when I mounted local file /usr/sbin/sendmail by -v /usr/sbin/sendmail:/usr/sbin/sendmail I got another error:
It looks like it happened because I am running Logstash in Docker.
That's crucial information! With containers running in bridge mode (the default), connections to localhost inside the container won't reach the host. You need to make sure you really connect to the host (e.g. by using its DNS name). Another option is to run the container in host network mode.
Though when I mounted local file /usr/sbin/sendmail by -v /usr/sbin/sendmail:/usr/sbin/sendmail I got another error:
That'll never work. The sendmail binary needs access to various other files.
In my case, ELK containers are connected to each other with with link. Is there any way to connect to a local host from a container to be able to run Sendmail or Postfix?
In my case, ELK containers are connected to each other with with link. Is there any way to connect to a local host from a container to be able to run Sendmail or Postfix?
I don't think there's a way to connect to the loopback interface of the host if you're running a container in bridge mode. As I said, either connect to the non-loopback interface on the host (e.g. by using its DNS name) or run the container in host network mode.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.