Created on 08-11-201601:02 PM - edited 08-17-201910:53 AM
With Apache NiFi 1.0 you can now act as a simple SMTP server (though it is recommended to sit behind a real SMTP MTA and just get mail forwards). It makes for an easy way to ingest mail, headers and attachments.
The first thing you will notice is the awesome new UI, which is much cleaner and a joy to use.'
First add a processor, ListenSMTP, this will be your mail gateway/SMTP server. As you can see there's also processors for extracting attachments and headers from Email.
You need to make sure you set Listening Port, SMTP hostname and Max. # of Connections.
The entire flow for mail processing is pretty simple, but easy to follow. We listen for SMTP over TCP Port (I chose 2025, but with Root access you could run on 25). I send the original flow file right to HDFS. I extract the attachments and put them in a separate HDFS directory and finally pull out the email headers and also send them to an HDFS file. I have a little test flow in the bottom to read a file and send email to our ListenSMTP for testing.
If you are running this on an HDP 2.4 sandbox, you will need to install Java 8 and set it as an alternative JDK.
Java 8 as an alternative and specified Java_HOME in top of bin/nifi.sh so I
could run with Java 8 which is required now.
To send a test SMTP message from the command line:
telnet localhost 2025
Connected to localhost.
Escape character is '^]'.
220 sandbox.hortonworks.com ESMTP Apache NiFi
RCPT TO: <email@example.com>
354 End data with