Configure email notifications in Flowable


#1

Hi,

Who knows how to enable/establish email notifications in Flowable.
It will be great if as soon as a task is assigned to someone Flowable will be send a email notification to a user.

Best regards,
Zholaman


#2

Hi,

this can be done by implementing a TaskListener.
Take a look in the docs here; TaskListeners

Regards,

Yvo


#3

Hi yvo,

I am sorry, maybe I didn’t expresse myself correctly.

I mean how Flowable can send email, how it can know what mail server/port to use and where I can point these settings.

Thank you in advance for your help!

Best regards,
Zholaman


#4

Hi.

Do you mean how to configure the mail server settings on the engine?
If you provide the engine configuration yourself then something like this;

<!-- mail server configurations -->
<property name="mailServerPort" value="5025" />

<property name="mailServers">
  <map>
    <entry key="myEmailTenant">
      <bean class="org.flowable.engine.cfg.MailServerInfo">
        <property name="mailServerHost" value="localhost" />
        <property name="mailServerPort" value="5025" />
        <property name="mailServerUseSSL" value="false" />
        <property name="mailServerUseTLS" value="false" />
        <property name="mailServerDefaultFrom" value="flowable@myTenant.com" />
        <property name="mailServerUsername" value="flowable@myTenant.com" />
        <property name="mailServerPassword" value="password" />
      </bean>
    </entry>
  </map>
</property>

If you’re using the Flowable UI apps then you can configure it as described here UI apps docs

F.e. in the flowable-ui-apps.properties;

email.host=
email.port=
email.useCredentials=
email.username=
email.password=

Is this what you are looking for?

Regards,

Yvo


#5

Dear yvo,

yes, it is what I am looking for!

Thank you a lot!

Best regards,
Zholaman


#7

Dear yvo,

I have set the below options (in flowable-task->flowable-ui-app.properties) but it seems not working. Before to write the post I have checked an access to the mail server by telnet:

email.host=192.168.0.1
email.port=25
email.useCredentials=false
email.username=johnny.depp (also tried: johnny.depp@company.com)
email.password=pass

Also how I can explicitly to point mail protocol f.e. SMTP, IMAP etc

Thanks!

Best regards,
Zholaman


#8

Hi

Based on the information provided I cannot tell what the reason is that it isn’t working.
Perhaps your mail server needs SSL / TLS …

You’re using the properties for the Task UI app. These are there for convenience. If you want more control on configuring the email server settings use a custom engine config.

We’re using Apache Commons Email for sending emails.
Also; the build in support is for SMTP not IMAP. (IMAP is not for sending but for receiving)

Hope this help.

Yvo


#9

Dear yvo,

our mail server use SMTP without SSL/TLS.

I tried to find any information about email sendings in Tomcat logs but no success, so if you have a time I will be appreciate to get any help/advice relating to this challenge.

Let me ask, how to custom engine config and use it in the Flowable?

Thanks!

Best regards,
Zholaman


#10

I really need more info on what you’re doing in orde to help.

If you’re using an EmailTask and somethings goes wrong sending the email the execution fails an exception is logged.
This must be visible.

F.e.

flowable-task | Caused by: org.apache.commons.mail.EmailException: Sending the email to the following server failed : localhost:25
flowable-task | at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1421)
flowable-task | at org.apache.commons.mail.Email.send(Email.java:1448)
flowable-task | at org.flowable.engine.impl.bpmn.behavior.MailActivityBehavior.execute(MailActivityBehavior.java:97)
flowable-task | … 94 more
flowable-task | Caused by: com.sun.mail.util.MailConnectException: Couldn’t connect to host, port: localhost, 25; timeout 60000;
flowable-task | nested exception is:
flowable-task | java.net.ConnectException: Connection refused
flowable-task | at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2053)
flowable-task | at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:697)
flowable-task | at javax.mail.Service.connect(Service.java:364)
flowable-task | at javax.mail.Service.connect(Service.java:245)
flowable-task | at javax.mail.Service.connect(Service.java:194)
flowable-task | at javax.mail.Transport.send0(Transport.java:253)
flowable-task | at javax.mail.Transport.send(Transport.java:124)
flowable-task | at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1411)
flowable-task | … 96 more
flowable-task | Caused by: java.net.ConnectException: Connection refused
flowable-task | at java.net.PlainSocketImpl.socketConnect(Native Method)
flowable-task | at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
flowable-task | at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
flowable-task | at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
flowable-task | at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
flowable-task | at java.net.Socket.connect(Socket.java:589)
flowable-task | at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:310)
flowable-task | at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:236)
flowable-task | at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2019)
flowable-task | … 103 more


#11

Dear yvo,

I am using above settings (in flowable-task->flowable-ui-app.properties), also I tried to assign a task to some AD users (by flowable-task WEB UI), that is all I am doing.

I do not use ‘EmailTask’, I do not know how to use it.

Please correct me if I am wrong, the Flowable should send a notification (to user email address) as soon as user get a task, is not it ?

Thank you for log example!

Best regards,
Zholaman


#12

Hi

This is not something that works automatically.
It has to be either modeled in the process or implemented in a TaskListener or implemented in the Task App.

Regards,

Yvo


#13

Hi Yvo,

I got it, thanks a lot!

Best regards,
Zholaman


#14

hi, i need an exemple that send email using that configuration inside flowable-ui-task.properties


#15

I, iam trying to configure flowable to send mail notification but i got erro:
10:12:37,308 [http-nio-8080-exec-15] ERROR org.flowable.rest.exception.BaseExceptionHandlerAdvice - Unhandled exception
org.flowable.engine.common.api.FlowableException: Could not send e-mail in execution 2572
at org.flowable.engine.impl.bpmn.behavior.MailActivityBehavior.handleException(MailActivityBehavior.java:406)
at org.flowable.engine.impl.bpmn.behavior.MailActivityBehavior.execute(MailActivityBehavior.java:102)
at org.flowable.engine.impl.agenda.ContinueProcessOperation.executeActivityBehavior(ContinueProcessOperation.java:248)
at org.flowable.engine.impl.agenda.ContinueProcessOperation.executeSynchronous(ContinueProcessOperation.java:154)
at org.flowable.engine.impl.agenda.ContinueProcessOperation.continueThroughFlowNode(ContinueProcessOperation.java:111)
at org.flowable.engine.impl.agenda.DebugContinueProcessOperation.continueThroughFlowNode(DebugContinueProcessOperation.java:52)
at org.flowable.engine.impl.agenda.ContinueProcessOperation.continueThroughSequenceFlow(ContinueProcessOperation.java:295)
at org.flowable.engine.impl.agenda.ContinueProcessOperation.run(ContinueProcessOperation.java:77)
at org.flowable.engine.impl.interceptor.CommandInvoker.executeOperation(CommandInvoker.java:88)
at org.flowable.engine.impl.interceptor.CommandInvoker.executeOperations(CommandInvoker.java:72)
at org.flowable.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:56)
at org.flowable.engine.impl.interceptor.BpmnOverrideContextInterceptor.execute(BpmnOverrideContextInterceptor.java:25)
at org.flowable.engine.common.impl.interceptor.TransactionContextInterceptor.execute(TransactionContextInterceptor.java:53)
at org.flowable.engine.common.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:72)
at org.flowable.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:49)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
at org.flowable.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:46)
at org.flowable.engine.common.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:30)
at org.flowable.engine.common.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:56)
at org.flowable.engine.common.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:51)
at org.flowable.engine.impl.TaskServiceImpl.completeTaskWithForm(TaskServiceImpl.java:230)
at org.flowable.app.service.runtime.FlowableTaskFormService.completeTaskForm(FlowableTaskFormService.java:114)
at org.flowable.app.service.runtime.FlowableTaskFormService$$FastClassBySpringCGLIB$$4bc0670c.invoke()
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673)
at org.flowable.app.service.runtime.FlowableTaskFormService$$EnhancerBySpringCGLIB$$a37e6c69.completeTaskForm()
at org.flowable.app.rest.runtime.TaskFormResource.completeTaskForm(TaskFormResource.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:317)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:114)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.flowable.app.filter.FlowableCookieFilter.doFilterInternal(FlowableCookieFilter.java:156)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:64)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:214)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:651)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:498)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:796)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1374)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.gmail.com:587
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:97)


#16

Hi, please i justa want to know where to find that configuration file?


#17

In the docs under Configuration - here?


#18

So where can i find flowable.cfg.xml file to configure


#19

A quick search of the sources says here.


#20

Hi Zholaman,
I have a similar requirement. I am creating a task say ““task 1” which after completion goes to email task . I configured email task by providing to , from and subject on flowable-modeler UI. In ““task 1”, i am providing a task listener with event ‘complete’ and giving Expression ‘Email’ . But when i try to complete ““task 1”, its gives internal server error and does not get completed. How to resolve this could you help.

Thanks in advance.
Shweta


#21

Hi yvo
I have a similar requirement. I am creating a task say “task 1” which after completion goes to email task . I configured email task by providing to , from and subject on flowable-modeler UI. In ““task 1" , i am providing a task listener with event ‘complete’ and giving Expression ‘Email’ .But when i try to complete ““task 1”, its gives internal server error and does not get completed. How to resolve this could you help.
Thanks in advance.
Shweta