DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • NiFi In-Memory Processing
  • Streamlining Data Lake ETL With Apache NiFi: A Practical Tutorial
  • How To View or Open MBOX File Using Best Solutions
  • Real-Time Analytics: All Data, Any Data, Any Scale, at Any Time

Trending

  • Artificial Intelligence, Real Consequences: Balancing Good vs Evil AI [Infographic]
  • Immutable Secrets Management: A Zero-Trust Approach to Sensitive Data in Containers
  • From Zero to Production: Best Practices for Scaling LLMs in the Enterprise
  • Beyond ChatGPT, AI Reasoning 2.0: Engineering AI Models With Human-Like Reasoning
  1. DZone
  2. Data Engineering
  3. Data
  4. Apache NiFi 1.0.0-BETA: Using the New ListenSMTP for Mail Routing

Apache NiFi 1.0.0-BETA: Using the New ListenSMTP for Mail Routing

Here is a tutorial on using the new version of Apache NiFi to listen for SMTP email and programmatically react and capture data.

By 
Tim Spann user avatar
Tim Spann
DZone Core CORE ·
Aug. 24, 16 · Tutorial
Likes (6)
Comment
Save
Tweet
Share
5.8K Views

Join the DZone community and get the full member experience.

Join For Free

Image title

The first thing you will notice is the awesome new UI, which is much cleaner and a joy to use.

Image title

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.

Image title

You need to make sure you set Listening Port, SMTP hostname and Max. # of Connections.

Image title

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.

Image title

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.

  • http://tecadmin.net/install-java-8-on-centos-rhel-and-fedora/

  • alternatives --config java

  • Pick Java 8

I added 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.

Image title

To send a test SMTP message from the command line:


telnet localhost 2025
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 sandbox.hortonworks.com ESMTP Apache NiFi
ehlo sandbox
250-sandbox.hortonworks.com
250-8BITMIME
250-SIZE 67108864
250 Ok
MAIL
FROM: <tim@sparkdeveloper.com>
250 Ok
RCPT TO: <tspann@hortonworks.com>
250 Ok
DATA
354 End data with
<CR><LF>.<CR><LF>
hello
.
250 Ok

A better way to test SMTP is with SWAKS See: https://debian-administration.org/article/633/Testing_SMTP_servers_with_SWAKS

  • From Mac: brew install swaks

  • From Centos/RHEL: sudo yum -y install swaks

Test Send Email:


swaks --to tspann@hortonworks.com --server localhost:2025
Received: from hw13125.home (localhost [127.0.0.1])  
by sandbox.hortonworks.com  with SMTP (Apache NiFi) id IRPEF4WI  
for tspann@hortonworks.com;  Wed, 10 Aug 2016 17:19:12 -0400 (EDT)
Date: Wed, 10 Aug 2016 17:19:12 -0400To:
tspann@hortonworks.com
From: tspann@hw13125.home
Subject: test Wed,
10 Aug 2016 17:19:12 -0400
X-Mailer: swaks v20130209.0 jetmore.org/john/code/swaks/
MIME-Version: 1.0
Content-Type: multipart/mixed; 
boundary="----=_MIME_BOUNDARY_000_98059"------=_MIME_BOUNDARY_000_98059
Content-Type: text/plain
This is a test mailing
------=_MIME_BOUNDARY_000_98059
Content-Type: application/octet-stream
Content-Disposition: attachment
Content-Transfer-Encoding:
BASE64
------=_MIME_BOUNDARY_000_98059--

It is very easy to configure send an email message to our server you need to put in a hostname and port.

Once your down building your flow, make sure you create a template and save the XML off to version control.

Creating a template has now moved to the Operate control.

If you get lost on what you are working for you can use the search feature from the top right.

Remember this is a beta product, not yet ready for production. Wait for HDF 2.0 for supported production usage.

Image title

Image title

Apache NiFi Mail (Apple)

Published at DZone with permission of Tim Spann, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • NiFi In-Memory Processing
  • Streamlining Data Lake ETL With Apache NiFi: A Practical Tutorial
  • How To View or Open MBOX File Using Best Solutions
  • Real-Time Analytics: All Data, Any Data, Any Scale, at Any Time

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: