Skip to content
QiTASC.com / intaQt Built-ins /
E-Mail Built-ins
/ .. /
E-Mail Built-ins





E-Mail Built-ins

E-mail Built-ins provide methods for preparing and sending E-mails from intaQt via a test case.

Configuration

Three configurations are required to use E-mail Built-ins:

  • The Email configuration, which sets the path to the template folder.

  • The Mail configuration, which is needed to set up the SMTP server.

  • The Reporting configuration must be active.

Email Configuration

A .txt file E-mail template must be created for the Email configuration. The template's first line is considered a subject, while all other lines will be considered the E-mail's content. The template is processed using FreeMarker, which enables the use of Context Objects.

Syntax

1
2
3
4
Email {
    isActive = <Boolean>
    templateFolderPath = <String>
}
Parameters

  • isActive - Enables E-mail Built-ins

    • May be true or false
  • templateFolderPath - The path to the location where E-mail templates are saved

Example

1
2
3
4
Email {
    isActive = true
    templateFolderPath = "../projects/templates"
}

Mail Configuration

This configuration defines the mail server settings, which are used for E-mail Built-ins and for reporting.

Syntax

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
Mail {
    isActive            = <boolean>
    host                = <String>
    port                = <Number>
    protocol            = <String>
    defaultEncoding     = <String>
    username            = <String>
    password            = <String>
    from                = <String>
    smtpAuth            = <Boolean>
    smtpStarttlsEnable  = <Boolean>
    smtpQuitwait        = <Boolean>
}

Parameters

  • isActive - `

    • true to activate E-mail Built-ins
    • false otherwise
  • host - The mail server IP address or host name

  • protocol - The E-mail protocol type

    • Must be one: smtp, smtps, pop3, pop3s, imap or imaps
  • port - The port that the E-mail server listens on

  • username - The username used to log in

  • password - The password associated with the username

  • defaultEncoding - The default character encoding, for example, UTF-8

  • from - The address from which the E-mail is sent

  • smtpAuth - Authenticates the user with the AUTH command

    • May be true or false
  • smtpStarttlsEnable -

    • true if an insecure SMTP connection should be upgraded to SSL/TLS if the server supports opportunistic TLS
    • false otherwise
  • smtpQuitwait - Defines whether to wait for a response to a QUIT command

    • If set to true, the server will wait for a response to a QUIT command
    • false immediately closes the connection

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
Mail {
    isActive            = true
    host                = "smtp.emailsrvr.com"
    username            = "batman@office.at"
    password            = "robin"
    from                = "alfred@office.at"
    port                = 25
    smtpAuth            = true
    smtpStarttlsEnable  = true
    smtpQuitwait        = true
}

Reporting Configuration

This configuration defines where reports are sent to and under what conditions. More information is available in the Reporting chapter.

Reporting

Syntax

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
Reporting {
    mailFrom = <String>
    mailTo = <String>
    immediatelyMailFailingFeature = <Boolean>
    mailFinalReportForFailures = <Boolean>
    alwaysMailFinalReport = <Boolean>
    reportsRootFoldername = <String>
    reportFoldernameDateFormat = <String>
    reportFoldernameSuffix = <String>
    reportArtifactFeaturePrefix = <String>
    reportArtifactScenarioPrefix = <String>
}

Parameters

  • mailFrom - The E-mail address the reports will be sent from

  • mailTo - The E-mail address(es) the reports will be sent to

    • Multiple comma-separated addresses may be specified
  • immediatelyMailFailingFeature -

    • true sends an HTML-only report specifying failures immediately after a feature has failed
    • false (default) otherwise
  • mailFinalReportForFailures -

    • true sends a zipped final report in cases of any failures
    • false (default) otherwise
  • alwaysMailFinalReport -

    • true sends a zipped final report in case features have failed or passed
    • false (default) otherwise
  • pathToReports - The path to the root folder where the reports will be stored

    • In order to prevent intaQt from using the wrong configuration files, this folder should not be in the same location as the project configuration files folder
  • dateFormat - Configures the date format that each report folder's name will start with

    • Default is set to yyyy-MM-dd-HH-mm-ss
  • folderSuffix - The folder name's suffix

    • The Feature name follows the suffix
  • reportArtifactFeaturePrefix (Optional, additional information below) - The feature name to be used for all report artifacts

    • Default template for the feature name
    • Any combination of placeholders and static strings are accepted
      • Special characters (such as, * , #) will be replaced by their UTF-16 codepoint
  • reportArtifactScenarioPrefix Optional, additional information below - The scenario name to be used for all report artifacts

    • Any combination of placeholders and static strings are accepted
    • Special characters (such as, * , #) will be replaced by their UTF-16 codepoint

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
Reporting {
    mailFrom = "reports@qitasc.com"
    mailTo   = "reports@qitasc.com, backup@qitasc.com"
    immediatelyMailFailingFeature = true
    mailFinalReportForFailures = true
    alwaysMailFinalReport = true
    reportsRootFoldername = "/Users/QiTASC/ProjectA/reports"
    reportFoldernameDateFormat = "yyyy-MM-dd_HH-mm-ss"
    reportFoldernameSuffix = "sms"
    reportArtifactFeaturePrefix = "{index} Custom feature name"
    reportArtifactScenarioPrefix = "{name} # {index}"
}

E-mail Built-ins Steps and Functions

Send E-mail Using Template

The following step sends an E-mail using the template defined in the E-mail configuration.

Syntax

1
Then send email using template <templateName String> to <emailAddress String>

Parameters

  • templateName - The name assigned to the E-mail template

  • emailAddress - The recipient's E-mail address

Example

1
Then send email using template "YourTemplate" to "office@example.com"

E-mail Builder Methods

The following methods are available to use with the EmailBuilder returned by Email.builder().

Syntax

1
<emailBuilder EmailBuilder> := Email.builder()

Returns

The EmailBuilder object.

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
stepdef "E-mail test"
    emailBuilder := Email.builder()
    emailBuilder
      .addRecipientTo("to@qitasc.com")
      .addRecipientCc("cc@qitasc.com")
      .addRecipientBcc("bcc@qitasc.com")
      .addReplyTo("replyTo@qitasc.com")
      .setFrom("from@qitasc.com")
      .setTemplate("template")
      .addAttachment("/Users/user/Documents/top-secret.txt")
    emailBuilder.send()
end

Add Recipient To (Required)

Adds the main recipient(s). At least one recipient is required to execute send(). The EmailBuilder remains active after the E-mail has been sent, meaning another recipient can be added and the E-mail can be re-sent as needed.

Syntax

1
<emailBuilder EmailBuilder>.addRecipientTo(<emailAddress String>)

Parameters

  • emailBuilder - The EmailBuilder object

  • emailAddress - The recipient's email address

    • Multiple addresses can be specified, but they must be comma-separated in the string

Example

1
emailBuilder.addRecipientTo("to@qitasc.com")

Set Template (Required)

Sets a template's file name which must be located in the configured templateFolderPath of the E-mail Configuration. This template extracts the E-mail's subject and body.

Syntax

1
<emailBuilder EmailBuilder>.setTemplate(<template String>)

Parameters

  • emailBuilder - The EmailBuilder object

  • templateName - The template's file name, which must be located in the Email configuration's templateFolderPath

Example

1
emailBuilder.setTemplate("template")

Add Attachment

Adds an attachment by specifying its path.

Syntax

1
<emailBuilder EmailBuilder>.addAttachment(<filePath String>)

Parameters

  • emailBuilder - The EmailBuilder object

  • filePath - The path to the attachment

Example

1
emailBuilder.addAttachment("/Users/user/Documents/top-secret.txt")

Add CC Recipient

Adds CC recipient address(es).

Syntax

1
<emailBuilder EmailBuilder>.addRecipientCc(<emailAddress String>)

Parameters

  • emailBuilder - The EmailBuilder object

  • emailAddress - The email address(es) of the CC'd party

Example

1
emailBuilder.addRecipientCc("help@qitasc.com, testing@qitasc.com")

Add BCC Recipient

Adds BCC recipient address(es).

Syntax

1
<emailBuilder EmailBuilder>.addRecipientBcc(<emailAddress String>)

Parameters

  • emailBuilder - The EmailBuilder object

  • emailAddress - The email address(es) of the BCC'd party

    • Multiple addresses can be specified, but they must be comma-separated in the string

Example

1
emailBuilder.addRecipientCc("billing@qitasc.com, accounts@qitasc.com")

Add Reply To

Adds a reply-to address(es).

Syntax

1
<emailBuilder EmailBuilder>.addReplyTo(<emailAddress String>)

Parameters

  • emailBuilder - The EmailBuilder object

  • emailAddress - The email address(es) that replies will be sent to

    • Multiple addresses can be specified, but they must be comma-separated in the string

Example

1
emailBuilder.addRecipientCc("customersupport@qitasc.com")

Set From

Sets the sender's from address. Some mail servers may block this functionality because of phishing detection.

Syntax

1
<emailBuilder EmailBuilder>.setFrom(<emailAddress String>)
Parameters

  • emailBuilder - The EmailBuilder object

  • emailAddress - The email address(es) that the E-mails will be sent via

    • Multiple addresses can be specified, but they must be comma-separated in the string

Example

1
emailBuilder.setFrom("customersupport@qitasc.com")

Set Template Parameters

Sets parameters to replace tags for the E-mail Template.

Syntax

1
<emailBuilder EmailBuilder>.setTemplateParameters(<parameters Map<String, Any>>)

Parameter

  • parameters - The map of key-value pairs to be used during the tag replacement process of a template

Send E-mail

Sends the email. The send() function must be included when using E-mail Built-ins. This method should be called after the e-mail has been constructed with the builder.

Syntax

1
<emailBuilder EmailBuilder>.send()

Parameter

  • emailBuilder - The EmailBuilder object

Example

1
2
3
4
5
6
7
stepdef "E-mail test"
    emailBuilder := Email.builder()
    emailBuilder
      .addRecipientTo("to@qitasc.com")
      .setTemplate("template")
    emailBuilder.send()
end