KB-1914 System emails/process emails are not sent with "Email body failed to render... Connection refused" error

Symptoms

When attempting to reset a password or use the Send Email Smart Service, the email fails to deliver.

With DEBUG logging turned on, the application server log will show the the following output: 

YYYY-MM-DD HH:MM:ss [Appian Work Item - 581 - NotificationsEmail : MailRequest] DEBUG com.appiancorp.process.engine.MailBody - lastName -> <LASTNAME>
YYYY-MM-DD HH:MM:ss [Appian Work Item - 581 - NotificationsEmail : MailRequest] DEBUG com.appiancorp.process.engine.MailBody - admin_username -> <ADMIN_USERNAME>
YYYY-MM-DD HH:MM:ss [Appian Work Item - 581 - NotificationsEmail : MailRequest] DEBUG com.appiancorp.process.engine.MailBody - tz -> <TIME_ZONE>
YYYY-MM-DD HH:MM:ss [Appian Work Item - 581 - NotificationsEmail : MailRequest] DEBUG com.appiancorp.process.engine.MailBody - admin_lastName -> <ADMIN_LASTNAME>
YYYY-MM-DD HH:MM:ss [Appian Work Item - 581 - NotificationsEmail : MailRequest] DEBUG com.appiancorp.process.engine.MailBody - admin_email -> <ADMIN_EMAIL>
YYYY-MM-DD HH:MM:ss [Appian Work Item - 581 - NotificationsEmail : MailRequest] DEBUG com.appiancorp.process.engine.MailBody - firstName -> <FIRST_NAME>
YYYY-MM-DD HH:MM:ss [Appian Work Item - 581 - NotificationsEmail : MailRequest] DEBUG com.appiancorp.process.engine.MailBody - temporaryPassword -> <TEMP_PASSWORD>
YYYY-MM-DD HH:MM:ss [Appian Work Item - 581 - NotificationsEmail : MailRequest] DEBUG com.appiancorp.process.engine.MailBody - calendarId -> <CALENDAR_TYPE>
YYYY-MM-DD HH:MM:ss [Appian Work Item - 581 - NotificationsEmail : MailRequest] DEBUG com.appiancorp.process.engine.MailBody - taskLink -> <TASK_LINK>
YYYY-MM-DD HH:MM:ss [Appian Work Item - 581 - NotificationsEmail : MailRequest] DEBUG com.appiancorp.process.engine.MailBody - admin_firstName -> <ADMIN_FIRSTNAME
YYYY-MM-DD HH:MM:ss [Appian Work Item - 581 - NotificationsEmail : MailRequest] DEBUG com.appiancorp.process.engine.MailBody - loginPageLink -> <LOGIN_PAGE>
YYYY-MM-DD HH:MM:ss [Appian Work Item - 581 - NotificationsEmail : MailRequest] DEBUG com.appiancorp.process.engine.MailBody - lang -> <LANGUAGE>
YYYY-MM-DD HH:MM:ss [Appian Work Item - 581 - NotificationsEmail : MailRequest] DEBUG com.appiancorp.process.engine.MailBody - timesent -> <TIME_SENT>
YYYY-MM-DD HH:MM:ss [Appian Work Item - 581 - NotificationsEmail : MailRequest] DEBUG com.appiancorp.process.engine.MailBody - email -> <EMAIL>
YYYY-MM-DD HH:MM:ss [Appian Work Item - 581 - NotificationsEmail : MailRequest] DEBUG com.appiancorp.process.engine.MailBody - username -> <USERNAME>

This shows that the email has been configured, the "to email" is correct, and the temporary password is being generated.

However, the application server log will also show the following error:

Exception:
javax.resource.spi.work.WorkCompletedException: com.appiancorp.process.engine.EmailBodyException: Email body failed to render: MailBody{<FILE_PATH_TO_EMAIL_TEMPLATE>}
...
Caused by: javax.ejb.EJBException: com.appiancorp.process.engine.EmailBodyException: Email body failed to render: MailBody{<FILE_PATH_TO_EMAIL_TEMPLATE>}
...
Caused by: com.appiancorp.process.engine.EmailBodyException: Email body failed to render: MailBody{<FILE_PATH_TO_EMAIL_TEMPLATE>}
...
Caused by: java.net.ConnectException: Connection refused (Connection refused)

Cause

When generating the email body, internal services in the Appian environment connect to the location specified in the conf.suite.SERVER_AND_PORT property, unless the properties conf.suite.MAIL_SCHEME and conf.suite.MAIL_SERVER_AND_PORT are set. The "Email body failed to render... Connection refused" error occurs when the internal services cannot connect to the specified location, which could be caused by one of the following issues:

  1. The Appian environment is configured with a web server to use HTTPS/SSL scheme, but the SSL certificate is not trusted, which causes the connection to fail.
  2. There could be a miss-match between the hosts file and the server/port for the mail server, which prevents it connecting to conf.suite.SERVER_AND_PORT.

Action

The error can be resolved by connecting directly to the mail server. Change/add the following lines in the custom.properties file:

conf.suite.MAIL_SCHEME=http
conf.suite.MAIL_SERVER_AND_PORT=localhost:<APP_SERVER_PORT>

These values are specified in the custom.properties file located in:

  • <APPIAN_HOME>/conf for Appian 18.2 and later.
  • <APPIAN_HOME>/ear/suite.ear/conf for Appian 18.1 and earlier.

Save the file and restart the application server for the changes to take effect. 

Affected Versions

This article applies to all versions of Appian. 

Last Reviewed: April 2019

Related
Recommended