Support Questions

Find answers, ask questions, and share your expertise
Announcements
We’ve updated our product names and community labels - click here for full details

PutEmail Timeout smtp.office365

avatar
Visitor

Hello everyone, 

I have been trying to solve an issue on my on-prem NiFi 2.4.0 application for a month which being PutEmail timeout errors. Specifically, we were using NiFi 1.9.0 and local smtp server to send mails, after updating to 2.4.0 we started using office365 smtp server. 

swaks --server smtp.office365.com --port 587 --tls --helo test.local --auth LOGIN --auth-user notifymail@****.com --auth-password '****' --from notifymail@****.com --to okan.ergun@****.com --header "Subject: Test Email" --body "Test SMTP Relay Service"

With the command above I never had timeouts, and every mail was successful from the application environment, although NiFi gets timeouts time to time and doesn't have any specific times to have timeouts.

 

Processor Details:

SMTP Hostname
smtp.office365.com
SMTP Port
587
Authorization Mode
Use Password
SMTP Username
notifymail@****.com
SMTP Password
Sensitive value set
SMTP Auth
true
SMTP STARTTLS
true
SMTP Socket Factory
${literal('')}
SMTP X-Mailer Header
NiFi
Attributes to Send as Headers (Regex)
No value set
Content Type
text/plain
From
notifymail@****.com
To
okan.ergun@****.com
CC
No value set
BCC
No value set
Reply-To
No value set
Subject
Test from NiFi
Message
Test
Flow file content as message
false
Input Character Set
UTF-8
Attach File
true
Include All Attributes In Message
false

PutEmail[id=99041462-0dcf-31ed-e46c-45b560f51973] Failed to send email for FlowFile[filename=48b2d732-915c-4a3e-a5d4-a1c0cdcb1e7c]: Couldn't connect to host, port: smtp.office365.com, 587; timeout -1; routing to failure: org.eclipse.angus.mail.util.MailConnectException: Couldn't connect to host, port: smtp.office365.com, 587; timeout -1;
nested exception is:
java.net.ConnectException: Connection timed out
- Caused by: java.net.ConnectException: Connection timed out

2026-02-25 13:24:41,375 ERROR [Timer-Driven Process Thread-5] o.a.nifi.processors.standard.PutEmail PutEmail[id=99041462-0dcf-31ed-e46c-45b560f51973] Failed to send email for StandardFlowFileRecord[uuid=48b2d732-915c-4a3e-a5d4-a1c0cdcb1e7c,claim=,offset=0,name=48b2d732-915c-4a3e-a5d4-a1c0cdcb1e7c,size=0]: Couldn't connect to host, port: smtp.office365.com, 587; timeout -1; routing to failure
org.eclipse.angus.mail.util.MailConnectException: Couldn't connect to host, port: smtp.office365.com, 587; timeout -1
at org.eclipse.angus.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2243)
at org.eclipse.angus.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:729)
at jakarta.mail.Service.connect(Service.java:364)
at jakarta.mail.Service.connect(Service.java:222)
at jakarta.mail.Service.connect(Service.java:171)
at jakarta.mail.Transport.send0(Transport.java:230)
at jakarta.mail.Transport.send(Transport.java:100)
at org.apache.nifi.processors.standard.PutEmail.send(PutEmail.java:654)
at org.apache.nifi.processors.standard.PutEmail.onTrigger(PutEmail.java:497)
at org.apache.nifi.processor.AbstractProcessor.onTrigger(AbstractProcessor.java:27)
at org.apache.nifi.controller.StandardProcessorNode.onTrigger(StandardProcessorNode.java:1272)
at org.apache.nifi.controller.tasks.ConnectableTask.invoke(ConnectableTask.java:244)
at org.apache.nifi.controller.scheduling.AbstractTimeBasedSchedulingAgent.lambda$doScheduleOnce$0(AbstractTimeBasedSchedulingAgent.java:59)
at org.apache.nifi.engine.FlowEngine.lambda$wrap$1(FlowEngine.java:105)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.net.ConnectException: Connection timed out
at java.base/sun.nio.ch.Net.connect0(Native Method)
at java.base/sun.nio.ch.Net.connect(Net.java:589)
at java.base/sun.nio.ch.Net.connect(Net.java:578)
at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:583)
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327)
at java.base/java.net.Socket.connect(Socket.java:751)
at java.base/java.net.Socket.connect(Socket.java:686)
at org.eclipse.angus.mail.util.SocketFetcher.createSocket(SocketFetcher.java:368)
at org.eclipse.angus.mail.util.SocketFetcher.getSocket(SocketFetcher.java:243)
at org.eclipse.angus.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2193)
... 19 common frames omitted
2026-02-25 13:24:41,375 INFO [Timer-Driven Process Thread-5] o.a.n.c.s.StandardProcessScheduler Stopping PutEmail[id=99041462-0dcf-31ed-e46c-45b560f51973]

 

Thank you for responding before-hand, I would appreciate any criticism also.

3 REPLIES 3

avatar
Community Manager

@okanergun Welcome to the Cloudera Community!

To help you get the best possible solution, I have tagged our NiFi experts @MattWho @mburgess  who may be able to assist you further.

Please keep us updated on your post, and we hope you find a satisfactory solution to your query.


Regards,

Diana Torres,
Senior Community Moderator


Was your question answered? Make sure to mark the answer as the accepted solution.
If you find a reply useful, say thanks by clicking on the thumbs up button.
Learn more about the Cloudera Community:

avatar
Master Collaborator

Hello @okanergun

According to https://issues.apache.org/jira/browse/NIFI-8630 the PutEmail processor was updated as mentioned here: 
"Upgraded javax.mail 1.4.7 to jakarta.mail 2.0.1 for PutEmail"
That was on 1.14.0, so in your case, you were using the old javax.mail and not the new jakarta.mail. 
There is a difference on the environment to take in consideration. 

The log you shared shows this: 

Couldn't connect to host, port: smtp.office365.com, 587; timeout -1

This means you do not have a socket timeout defines, which could case the processor to hang and report those timeouts when OS tells so. 
You can try to add these setting: 
-Dmail.smtp.connectiontimeout=30000
-Dmail.smtp.timeout=30000
-Dmail.smtp.writetimeout=30000
https://eclipse-ee4j.github.io/angus-mail/docs/api/org.eclipse.angus.mail/org/eclipse/angus/mail/smt... 

Also, make sure you have "Concurrent Tasks" under the PutEmail processor set to 1. 
This kind of SMTP for Microsoft may block parallel connections. 


Regards,
Andrés Fallas
--
Was your question answered? Please take some time to click on "Accept as Solution" below this post.
If you find a reply useful, say thanks by clicking on the thumbs-up button.

avatar
Community Manager

@okanergun Has the reply helped resolve your issue? If so, please mark the appropriate reply as the solution, as it will make it easier for others to find the answer in the future. Thanks.


Regards,

Diana Torres,
Senior Community Moderator


Was your question answered? Make sure to mark the answer as the accepted solution.
If you find a reply useful, say thanks by clicking on the thumbs up button.
Learn more about the Cloudera Community: