# Flowable engine is taking default mail configuration occasionally

**URL:** <https://forum.flowable.org/t/flowable-engine-is-taking-default-mail-configuration-occasionally/10353>\
**Category:** Flowable Engine\
**Created:** [March 22, 2023, 1:44pm UTC](https://forum.flowable.org/t/flowable-engine-is-taking-default-mail-configuration-occasionally/10353 "2023-03-22T13:44:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pravinpsa](https://avatars.discourse-cdn.com/v4/letter/p/b3f665/32.png) [@pravinpsa](https://forum.flowable.org/u/pravinpsa)\
**Post date:** [March 22, 2023, 1:44pm UTC](https://forum.flowable.org/t/flowable-engine-is-taking-default-mail-configuration-occasionally/10353/1 "2023-03-22T13:44:14Z")

</div>

Hi Team,

I have created a BPMN with mail service, If the task reaches the due date it will trigger automatic mails based on pattern given in Time cycle in boundary event and I used the below configuration for mail server, am getting the mail as I expected but the issue is occasionally am getting the below error seems the flowable engine is taking default mail configuration, But the issue is occurring randomly.

_ **BPMN** _

![Reminder](https://canada1.discourse-cdn.com/flex035/uploads/flowable/original/2X/f/f9740d5229e55ed4109871db22eee9beaf29fb4e.png)

_ **Configuration :** _

```auto
flowable.mail.server.default-from=xxx@yyy.com
flowable.mail.server.host=xxx.yyy.com
flowable.mail.server.port=25
flowable.mail.server.username=xxx
flowable.mail.server.password=yyy

```

_ **Error** _

```auto
org.flowable.common.engine.api.FlowableException: Could not send e-mail in execution be12fd84-c8b3-11ed-b122-0a18177a00ea
	at org.flowable.engine.impl.bpmn.behavior.MailActivityBehavior.handleException(MailActivityBehavior.java:497)
	at org.flowable.engine.impl.bpmn.behavior.MailActivityBehavior.execute(MailActivityBehavior.java:130)
	at org.flowable.engine.impl.agenda.ContinueProcessOperation.executeActivityBehavior(ContinueProcessOperation.java:286)
	at org.flowable.engine.impl.agenda.ContinueProcessOperation.executeSynchronous(ContinueProcessOperation.java:168)
	at org.flowable.engine.impl.agenda.ContinueProcessOperation.continueThroughFlowNode(ContinueProcessOperation.java:123)
	at org.flowable.engine.impl.agenda.ContinueProcessOperation.run(ContinueProcessOperation.java:86)
	at org.flowable.common.engine.impl.AbstractEngineConfiguration.lambda$new$0(AbstractEngineConfiguration.java:195)
	at org.flowable.engine.impl.interceptor.CommandInvoker.executeOperation(CommandInvoker.java:130)
	at org.flowable.engine.impl.interceptor.CommandInvoker.executeOperations(CommandInvoker.java:114)
	at org.flowable.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:72)
	at org.flowable.engine.impl.interceptor.BpmnOverrideContextInterceptor.execute(BpmnOverrideContextInterceptor.java:26)
	at org.flowable.common.engine.impl.interceptor.TransactionContextInterceptor.execute(TransactionContextInterceptor.java:53)
	at org.flowable.common.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:98)
	at org.flowable.common.spring.SpringTransactionInterceptor.lambda$execute$0(SpringTransactionInterceptor.java:57)
	at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140)
	at org.flowable.common.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:57)
	at org.flowable.common.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:30)
	at org.flowable.common.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:56)
	at org.flowable.common.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:51)
	at org.flowable.job.service.impl.asyncexecutor.ExecuteAsyncRunnable.executeJob(ExecuteAsyncRunnable.java:127)
	at org.flowable.job.service.impl.asyncexecutor.ExecuteAsyncRunnable.run(ExecuteAsyncRunnable.java:115)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.commons.mail.EmailException: Sending the email to the following server failed : localhost:1025
	at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1469)
	at org.apache.commons.mail.Email.send(Email.java:1496)
	at org.flowable.engine.impl.bpmn.behavior.MailActivityBehavior.execute(MailActivityBehavior.java:125)
	... 22 common frames omitted
Caused by: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: localhost, 1025; timeout 60000
	at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2210)
	at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:722)
	at javax.mail.Service.connect(Service.java:342)
	at javax.mail.Service.connect(Service.java:222)
	at javax.mail.Service.connect(Service.java:171)
	at javax.mail.Transport.send0(Transport.java:230)
	at javax.mail.Transport.send(Transport.java:100)
	at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1459)
	... 24 common frames omitted
Caused by: java.net.ConnectException: Connection refused (Connection refused)
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
	at java.net.Socket.connect(Socket.java:589)
	at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:333)
	at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:214)
	at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2160)
	... 31 common frames omitted

```

Did I miss any configuration ? Kindly suggest me to overcome this issue.

`flowable.version - 6.7.0`

---

<div class="post-metadata">

**Author:** ![gdharley](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/gdharley/32/2695_2.png) [@gdharley](https://forum.flowable.org/u/gdharley)\
**Post date:** [March 22, 2023, 1:48pm UTC](https://forum.flowable.org/t/flowable-engine-is-taking-default-mail-configuration-occasionally/10353/2 "2023-03-22T13:48:15Z")

</div>

Are you running in a cluster configuration?  
This behavior would suggest one of the nodes is missing the mail configuration, perhaps not running the production profile or something similar.

---

<div class="post-metadata">

**Author:** ![pravinpsa](https://avatars.discourse-cdn.com/v4/letter/p/b3f665/32.png) [@pravinpsa](https://forum.flowable.org/u/pravinpsa)\
**Post date:** [March 23, 2023, 6:36am UTC](https://forum.flowable.org/t/flowable-engine-is-taking-default-mail-configuration-occasionally/10353/3 "2023-03-23T06:36:33Z")

</div>

Hi @gdharley ,

We are running flowable engine in two instances both the instance were pointing same DB and both the instances have the mail configuration, But I don’t know why this issue is occurring occasionally.

Is there any way to debug this ?

Thanks for the reply.

---

<div class="post-metadata">

**Author:** ![gdharley](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/gdharley/32/2695_2.png) [@gdharley](https://forum.flowable.org/u/gdharley)\
**Post date:** [March 23, 2023, 4:52pm UTC](https://forum.flowable.org/t/flowable-engine-is-taking-default-mail-configuration-occasionally/10353/4 "2023-03-23T16:52:02Z")

</div>

Debugging this will be very difficult as it happens so infrequently, however you can mitigate the issue by setting the email task to be asynchronous. That way, if it does fail, it will be automatically retried up to 3 times.

---

<div class="post-metadata">

**Author:** ![pravinpsa](https://avatars.discourse-cdn.com/v4/letter/p/b3f665/32.png) [@pravinpsa](https://forum.flowable.org/u/pravinpsa)\
**Post date:** [March 24, 2023, 4:52am UTC](https://forum.flowable.org/t/flowable-engine-is-taking-default-mail-configuration-occasionally/10353/5 "2023-03-24T04:52:32Z")

</div>

Hi @gdharley ,

As you mentioned in previous reply the configuration is missing in one of the Environment ( _we are using Jenkins to build it is taking configuration from some other location not from the source code so we missed_ ) , After we fixed that, It is working as expected.

Thanks !
