SMTP Send
SMTP Send
Section titled “SMTP Send”Type: smtp-send · Package: SMTP / IMAP Email Activities v1.0.5
Sends an email through an SMTP server, without Outlook installed. It supports several recipients, carbon copy (CC) and blind carbon copy (BCC), reply-to address, text or HTML body, and attachments. It is the activity for sending notifications, reports and confirmations from a robot, also in unattended execution.
How it works
Section titled “How it works”- Builds the message: sender (
from, orusernameif not set), recipients, subject, body (text or HTML depending onisHtml) and attachments. If an attachment is missing, it fails before connecting, so no incomplete email goes out. - Connects to
host:portwith thesecurityencryption (defaultautoon port587: STARTTLS if the server offers it), signs in withusernameandpassword, sends and disconnects.
Recipients (to, cc, bcc) can be a text with addresses separated by commas ("ana@company.com, luis@company.com") or a list. Each address can carry a display name: "Ana Smith <ana@company.com>". The connection data is that of the sending server.
Each run sends a new email: if you put it inside a Retry, a retry after a send that did go through produces a duplicate.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
host | string | — | SMTP server (e.g. smtp.gmail.com). |
username | string | — | Username used to sign in (usually the full address). |
password | credential | — | Password or App Password. Use credential("name")["password"]. |
to | string | List | — | Recipient(s): text with comma-separated addresses, or a list of addresses. At least one is required. |
subject | string | — | Subject. |
body | string | — | Email body (plain text, or HTML with isHtml = true). |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
port | int | 587 | SMTP port. With security = ssl it is usually 465. |
from | string | username | Sender address; accepts "Name <address>". Many servers require it to be the signed-in account or an authorized alias. |
replyTo | string | — | Address that receives replies (Reply-To). |
isHtml | bool | false | The body is HTML. |
cc | string | List | — | CC: comma-separated text or list. |
bcc | string | List | — | BCC: comma-separated text or list. |
attachments | string | List | — | A text with one file path, or a list of paths. All files must exist. |
security | string | "auto" | Encryption: auto, none, ssl or starttls. See Encryption and ports. |
Output
Section titled “Output”This activity does not return a value. The log says how many recipients (to + cc + bcc) the email was sent to.
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
'host' is required. (and the same for username, subject, body) | The parameter is missing or the expression returned null. For an empty body use "". |
At least one recipient is required in 'to'. | to is empty or the list contains no texts. |
Attachment file not found. | A path in attachments does not exist. Check it first with File Exists; the email is not sent. |
| Error parsing an address | An address in from, to, cc, bcc or replyTo is invalid (for example, separated with ; instead of a comma). |
| Server authentication error | Wrong username or password, or the account requires an App Password. |
| Connection or TLS error | Wrong host or port, or security does not match the port (for example ssl on 587). Use 587 + auto/starttls or 465 + ssl. |
Example
Section titled “Example”Send an invoice attached using secure credentials, with a copy to the collections team:
SMTP Send host = "smtp.gmail.com" username = credential("mail-bot")["user"] password = credential("mail-bot")["password"] from = "Billing <" + credential("mail-bot")["user"] + ">" to = customer.email cc = "collections@company.com" subject = "Invoice " + invoiceNumber body = "<p>Please find invoice <b>" + invoiceNumber + "</b> attached. Thank you for your purchase.</p>" isHtml = true attachments = arr("C:/invoices/" + invoiceNumber + ".pdf")Related activities
Section titled “Related activities”- IMAP Read — read incoming emails.
- Outlook Send Email — alternative through the Outlook client.