Search code examples
smtplogstashimapelastic-stack

How to configure Logstash IMAP plugin to fetch email from SMTP Server


I have a SMTP Server (using virtual SMTP server on windows server 2012), and a CentOS machine. On CentOS machine, I installed ELK. Now I want to configure Logstash to get email from SMTP server by using IMAP plugin.

Please help me.

Thank you so much.


Solution

  • The below logstash configuration should work. Please change the settings and output plugins as per your need.

    logstash.conf

    input{
        imap{
            host => "SERVER_IP"
            user => "USERNAME"
            password => "************"
            port => PORT_NUMBER
            secure => true/false
            check_interval => INTERVAL_SECONDS
        }
    }
    output{
        stdout{
            codec => "json"
        }
    }
    

    Then start logstash using the below command

    bin/logstash -f "logstash.conf"
    

    This should check emails for every configured check_interval duration in seconds and trigger an event.