sendMail is an operation that sends one or several emails to a SMTP server.
In a development environment on Windows, you could install the PaperCut Test SMTP server to receive, test, and read the emails sent.
In the below pipeline, we:
pipeline:
- name: "Select"
comment: "This operation select the resources to send"
operation: "select"
args:
data-selector: "email/*.csv@howto"
- name: "Send"
comment: "Send the selected resources as email attachment"
operation: "sendmail"
args:
target-uri: "@smtp" # smtp is the default smtp connection and is therefore optional
to: "[email protected]"
subject: "Demo: How to send resources"
txt: |
Please, find attached the report data
If you execute this pipeline
tabli flow execute pipeline/email_resources.yml@howto
Output:
########
Executing the pipeline email_resources
########
List of executions
ExecutionId OperationName DataPathsCount DataPathsList
----------- ------------- -------------- -------------------------
1 select 1 email\analytics.csv@howto
2 send 1 email\analytics.csv@howto
pipeline:
- name: "Define"
comment: "This operation defines a data path with the expected columns of a mailing list"
operation: "define"
args:
data-resource:
data-definition:
columns: ["to","from","subject","txt","html"]
data:
- [ "[email protected]", "[email protected]", "Email for foo", "A textual email body", "<html><body><h1>A html email body</h1></body></html>"]
- [ "[email protected]", "[email protected]", "Email for bar", "A textual email body", "<html><body><h1>A html email body</h1></body></html>"]
- name: "Send"
comment: "Send the email"
operation: "sendmail"
args:
target-uri: "@smtp" # smtp is the default smtp connection and is therefore optional
granularity: "record"
If you execute this pipeline
tabli flow execute pipeline/email_list.yml@howto
Output:
########
Executing the pipeline email_list
########
List of executions
ExecutionId OperationName DataPathsCount DataPathsList
----------- ------------- -------------- -------------------------------------------
1 define 1 12b25b90-3b0e-4005-8119-c2c9cd69cca9@memory
2 send 1 12b25b90-3b0e-4005-8119-c2c9cd69cca9@memory
The result in PaperCut.
Argument | Default | Description |
---|---|---|
target-uri | @smtp | the smtp server to use to send the email (by default, the local smtp server without any authentication) |
to | to property of the smtp connection | the receiver email addresses |
to_names | to_names property of the smtp connection | the receiver email addresses name |
from | from property of the smtp connection if not found user@host | the sender email address |
from_name | from_name property of the smtp connection if not found user@host | the sender email address name |
cc | cc property of the smtp connection | the carbon copy email addresses (separated by a ;) |
cc_names | cc_names property of the smtp connection | the carbon copy email address names (separated by a ;) |
bcc | bcc property of the smtp connection | the blind carbon copy email addresses (separated by a ;) |
bcc_names | bcc_names property of the smtp connection | the blind carbon copy email address names (separated by a ;) |
subject | the logical name of the resource | the email subject |
txt | the text body of the email | |
html | the html body of the email | |
body-type | ['html','txt'] | the resources type seen as email body (ie html and txt file are seen as email body and not attachment) |
granularity | resource | with the value: - resource: one email is send with all resources attached - record - an email is send by record (mailinglist) |
log-target-uri | A target-uri | the location of the logs that stores the emails sent (By default, the table smtp in the log). You can use this parameter to point to a table in your database to exclude email from a list in your selection. |
When running the send operation by record, the send operation except the following columns:
Column Name | Optionality | Default | Description |
---|---|---|---|
to | In production, mandatory, in other environment, the to property of the smtp connection is used | The to address(es) | |
to_names | yes | from property of the smtp connection | The to address names |
from | yes | from property of the smtp connection | The from address (only one) |
from_name | yes | The name of the from address | The from address name |
cc | yes | The cc property of the smtp connection | The cc address (separated by a ;) |
cc_names | yes | The cc_names property of the smtp connection | The names of the cc address |
bcc | yes | The bcc property of the smtp connection | The bcc address (separated by a ;) |
bcc_names | yes | The bcc_names property of the smtp connection | The names of the bcc address |
subject | yes | logical name of the resource and record id | |
txt | Mandatory if html is not present | none | The email text body |
html | Mandatory if txt is not present | none | The email html body |
No attachements can be send for now in a record run.