Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
minLevel1
maxLevel3
outlinefalse
typelist
printablefalse

How to send Emails in PIPEFORCE?

In PIPEFORCE you can send email messages out-of-the-box using the mail.send command.

...

Code Block
languageyaml
pipeline:
 - mail.send:
    to: "recipient@domain.tld"
    subject: "This is the subject"
    message: |
      Hello recipient,
      this is an email sent from a pipeline.
      Greetings

Email Templates

There are different possibilities in PIPEFORCE to set the email data dynamically.

Using PEL

As usual, you can use the Pipeline Expression Language (PEL) in order to define placeholders in the command parameters. For example:

Code Block
languageyaml
vars:
  name: "Sam"
  email: "recipient@domain.tld"

pipeline:
 - mail.send:
    to: ${vars.email}
    subject: "This is for ${vars.name}"
    message: |
      Hello ${vars.name},
      this is an email sent from a pipeline.
      Greetings

Using a Transformer Command

You can use a transformer command like transform.ftl in order to render the message. For example:

...

Code Block
languageyaml
vars:
  name: "Sam"
  email: "recipient@domain.tld"

pipeline:

  - transform.ftl:
      template: "uri:property:global/app/myapp/template/email"

  - mail.send:
      to: ${vars.email}
      subject: "This is for ${vars.name}"

Using a Custom URI

Instead of defining a separate transformer command in the pipeline, you can use a Custom URI which points inline to a template. For example:

...

Code Block
languageyaml
pipeline:

  - mail.send:
      to: "recipient@domain.tld"
      subject: "This is a subject"
      message: "$uri:property:global/app/myapp/template/email"
      model: {"name": "Sam"}

Email Attachments

In case you would like to add attachments, you can use the parameter attachments to do so.

From Body

One approach is to load the attachments into a scope, like vars or the body first and then refer to them using a PEL inside the parameter attachments. For example:

...

Using this approach it is also possible to create the attachments dynamically on-the-fly in the pipeline (for example by using a template engine) and then add them finally to the email.

From Custom URI

Another approach to add attachments to an email is by using a Custom URI which points to the location of the attachments. For example:

...

Info

You can add multiple attachments by separating them by comma.

HTML Emails

Emails are sent by default using a base HTML skeleton. Any message is placed as text inside this HTML skeleton. HTML tags will be escaped by default.

...

This will produce an email message output similar to this:

...

Bulk Emails

Sending multiple emails to multiple recipients with dynamic content can be done using the mail.send command in combination with the foreach command.

...