Skip to main content

Version: 24.10

Email Service

The Email Service is called whenever a notification needs to be sent to a Journey Manager user. Journey Manager provides email-based implementations for notification.

info

You can implement your own notification services that can use email or other communication channels; for example, you could provide an SMS notification service.

The Email Service can be configured on multiple levels, and is resolved in the following order:

  • Form Version
  • Organization
  • Global Service

The global default Email Service is used throughout, but can be overridden on the organization and form version level for sending submission related messages to applicants.

Service Invoke Parameters

Parameters are not nullable except where otherwise indicated.

ParameterDescription
svcDefSvcDef
A service definition value object.
txnTxn
Nullable. A transaction record value object.
subjectString
The email subject.
messageString
Nullable. The email body message.
fromAddressString
Nullable. The sender address.
replyToAddressString
Nullable. The address to use when the recipient replies to the message.
toAddressString
The email addresses of the main recipients of the email.
ccAddressString
Nullable. The email addresses of recipients that you want to copy the email to publicly.
bccAddressString
Nullable. The email addresses of recipients that you want to copy the email to privately (Blind Carbon Copy).
attachmentMapMap<string byte>
Nullable. A map of attached files (containing filename/file data entries).

Error Handling

If an error occurs, it is recorded in the Journey Manager database error log.

Templates

Service

import com.avoka.core.groovy.GroovyLogger as logger
import com.avoka.tm.svc.*
import com.avoka.tm.vo.*
import javax.servlet.http.*

class FluentEmailService {

/**
* Perform send email
*/
void invoke(SvcDef svcDef,
Txn txn,
String subject,
String message,
String fromAddress,
String replyToAddress,
String toAddress,
String ccAddress,
String bccAddress,
Map<string byte>attachmentMap) {

// TODO: perform business logic

new Emailer()
.setSubject(subject)
.setMessage(message)
.setFromAddress(fromAddress)
.setReplyToAddress(replyToAddress)
.setToAddress(toAddress)
.setCcAddress(ccAddress)
.setBccAddress(bccAddress)
.setAttachmentMap(attachmentMap)
.setTxn(txn)
.sendEmail()
}
}

Unit Test

import com.avoka.core.groovy.GroovyLogger as logger
import com.avoka.tm.svc.*
import com.avoka.tm.test.*
import com.avoka.tm.vo.*
import org.junit.Test

class UnitTest extends AbstractJUnitTest {

/*
* Perform service unit test
*
* throws exception if unit test fails
*/
@Test
void testEmailService() throws Exception {

Txn txn = new MockVoBuilder().createTxnOpened()

Map params = [
"svcDef": svcDef,
"txn": txn,
"subject": "Email Subject",
"message": "Email Message",
"fromAddress": null,
"replyToAddress": null,
"toAddress": "[email protected]",
"ccAddress": null,
"bccAddress": null,
"attachmentMap": null,
]

new ServiceInvoker(svcDef).invoke(params)
}
}