# SMTP Email Sender for Workflow Notifications (`nimbryxo-studio/smtp-email-sender-for-workflow-notifications`) Actor

Send a plain text or HTML email through your own SMTP account from an Apify run. Supports multiple recipients, CC/BCC, Reply-To, and file attachments.

- **URL**: https://apify.com/nimbryxo-studio/smtp-email-sender-for-workflow-notifications.md
- **Developed by:** [Nimbryxo-studio](https://apify.com/nimbryxo-studio) (community)
- **Categories:** Automation, Developer tools, Integrations
- **Security:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.49 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## SMTP Email Sender for Workflow Notifications

Most scraping and automation pipelines end with "now tell someone." This actor is that last step: point it at your own SMTP account — Gmail, Outlook, Yahoo, SendGrid, Mailgun, Amazon SES, or any other mail server — and it sends one email on your behalf. Trigger it standalone, chain it after another actor finishes, or call it from a webhook so a run's results land in an inbox automatically.

### What this actor does

- Sends a single email per run through the SMTP credentials you provide
- Supports plain text, HTML, or both in the same message
- Adds CC, BCC, and Reply-To addresses, with multiple recipients per field
- Attaches files you supply as base64-encoded content
- Sends from the address in `smtpUser`, so the SMTP username should be the mailbox you want the email to come from
- Reports whether CC, BCC, or a Reply-To address were used, alongside the message's own delivery details

### Output per sent email

- `status` — delivery status (`sent`)
- `to` — recipient address(es)
- `cc` — CC address(es); an empty string when none were set
- `bcc` — BCC address(es); an empty string when none were set
- `subject` — email subject line
- `replyTo` — reply-to address; an empty string when not set
- `hasHtml` — whether an HTML body was included
- `hasText` — whether a plain text body was included
- `attachmentCount` — number of attachments supplied in `attachments` (an entry with invalid or empty data is skipped from the message but still counted here)
- `smtpHost` — SMTP server used to send the message
- `smtpPort` — SMTP port used
- `sentFrom` — sender address (your SMTP username)
- `messageId` — the message's Message-ID header; currently an empty string, because the actor doesn't assign one before sending
- `sentAt` — ISO 8601 timestamp of when the message was sent

A record is written only when the SMTP server accepts the message. If validation or sending fails, the run fails with the reason in its status message and the dataset stays empty.

### Input

| Field | Type | Default | Description |
|---|---|---|---|
| `to` | string | – | Recipient address(es), comma-separated. Required. |
| `cc` | string | – | CC address(es), comma-separated. |
| `bcc` | string | – | BCC address(es), comma-separated. |
| `subject` | string | – | Email subject line. Required. |
| `text` | string | – | Plain text body. At least one of `text` or `html` is required. |
| `html` | string | – | HTML body. At least one of `text` or `html` is required. |
| `replyTo` | string | – | Address replies should go to, if different from the sender. |
| `attachments` | array | – | Files to attach, each as `{ "filename": ..., "data": "<base64>" }`. |
| `smtpHost` | string | – | SMTP server hostname (e.g. `smtp.gmail.com`). Required. |
| `smtpPort` | integer | `587` | SMTP server port: `587` for STARTTLS, `465` for direct SSL, or any other port your server uses. |
| `smtpUser` | string | – | SMTP login username. Required. |
| `smtpPassword` | string | – | SMTP login password or API key. Required; stored encrypted. |
| `useTls` | boolean | `true` | Encrypt the connection: direct SSL on port `465`, STARTTLS on every other port. Turn off only for servers that accept unencrypted connections (e.g. some port `25` relays). |

#### Example: plain report email via Gmail

```json
{
  "to": "team@example.com",
  "subject": "Daily scrape complete",
  "text": "The nightly run finished with 1,204 new records.",
  "smtpHost": "smtp.gmail.com",
  "smtpPort": 587,
  "smtpUser": "you@gmail.com",
  "smtpPassword": "your-app-password",
  "useTls": true
}
```

#### Example: HTML report with an attachment and CC via Mailgun

```json
{
  "to": "alice@example.com, bob@example.com",
  "cc": "manager@example.com",
  "subject": "Weekly Export",
  "html": "<h1>Weekly Export</h1><p>See the attached CSV.</p>",
  "attachments": [
    { "filename": "export.csv", "data": "bmFtZSxjb3VudA0KZm9vLDEyMw==" }
  ],
  "smtpHost": "smtp.mailgun.org",
  "smtpPort": 587,
  "smtpUser": "reports@mg.example.com",
  "smtpPassword": "your-mailgun-smtp-password"
}
```

#### Example: alert with a custom Reply-To via Outlook / Office 365

```json
{
  "to": "oncall@example.com",
  "subject": "Threshold exceeded",
  "html": "<p>Error rate crossed 5% in the last hour.</p>",
  "replyTo": "alerts@example.com",
  "smtpHost": "smtp.office365.com",
  "smtpPort": 587,
  "smtpUser": "monitoring@yourcompany.com",
  "smtpPassword": "your-mailbox-password"
}
```

### Use cases

- **Run completion alerts** — email a summary the moment a scraper or data pipeline finishes
- **Scheduled reports** — attach a CSV or JSON export and send it on a recurring schedule
- **Threshold monitoring** — fire an email when a webhook detects a condition worth flagging
- **Team notifications** — CC or BCC a distribution list whenever a workflow step completes
- **Lightweight transactional mail** — confirmations, digests, or reminders from a no-code pipeline

### FAQ

**Which mail providers work with this actor?**
Any provider that exposes SMTP, including Gmail, Outlook/Office 365, Yahoo Mail, SendGrid, Mailgun, and Amazon SES. You supply the host, port, username, and password for your own account. Because the From address is always your SMTP username, providers whose username is an email address (Gmail, Outlook, Yahoo, Mailgun) work out of the box. SendGrid (username `apikey`) and Amazon SES (an access-key style username) will usually reject the message, since that username isn't a verified sender address.

**Do I need an app password for Gmail?**
Yes, if your Google account has 2-factor authentication enabled (recommended). Generate one under Google Account > Security > App Passwords and use it as `smtpPassword`.

**Can I send to several people at once?**
Yes. Put comma-separated addresses in `to`, `cc`, or `bcc`.

**Why are `cc` or `replyTo` empty in my output record?**
Those fields reflect what you set on input — if you didn't supply a CC or Reply-To address, the record carries an empty string for that field rather than omitting it.

**Is my SMTP password safe?**
`smtpPassword` is marked as a secret input, so Apify encrypts it at rest and masks it in the console and logs.

**How large can an attachment be?**
This depends on your SMTP provider's own limits (Gmail allows up to 25 MB per message). Keep total attachment size well under that to avoid provider-side rejection.

**What if the SMTP server rejects the connection?**
The run fails with the server's own error message (authentication failure, connection refused, timeout, etc.) so you can correct the host, port, or credentials.

**Can I use port 465 instead of 587?**
Yes. Set `smtpPort` to `465` and keep `useTls` enabled; the actor connects over direct SSL for that port instead of STARTTLS.

**Can I choose a different From address or display name?**
No. The message is sent from the `smtpUser` address exactly as entered. Use `replyTo` if replies should go somewhere else.

**Does this actor store or forward my emails anywhere?**
No. Each run only sends the single message you configure through your own SMTP server; nothing is retained beyond the delivery confirmation record.

# Actor input Schema

## `to` (type: `string`):

Recipient email address(es). Separate multiple addresses with commas. Example: 'user@example.com' or 'alice@example.com, bob@example.com'

## `cc` (type: `string`):

Carbon copy recipient(s). Separate multiple addresses with commas.

## `bcc` (type: `string`):

Blind carbon copy recipient(s). Separate multiple addresses with commas. BCC addresses are hidden from other recipients.

## `subject` (type: `string`):

Email subject line.

## `text` (type: `string`):

Plain text email body. At least one of 'Plain Text Body' or 'HTML Body' must be provided. If both are set, email clients choose which to display.

## `html` (type: `string`):

HTML email body. Takes priority over plain text in most email clients. Example: '<h1>Hello</h1><p>This is a test.</p>'

## `replyTo` (type: `string`):

Reply-to email address. When recipients reply, their response goes to this address instead of the sender.

## `attachments` (type: `array`):

File attachments as base64-encoded objects. Each item needs 'filename' (string) and 'data' (base64 string). Example: \[{"filename": "report.pdf", "data": "base64data..."}]

## `smtpHost` (type: `string`):

SMTP server hostname. Examples: smtp.gmail.com, smtp.office365.com, smtp.mail.yahoo.com, smtp.mailgun.org, smtp.sendgrid.net

## `smtpPort` (type: `integer`):

SMTP server port. Use 587 for STARTTLS (recommended), 465 for SSL/TLS, or 25 for unencrypted.

## `smtpUser` (type: `string`):

SMTP login username. Usually your full email address. For SendGrid, use 'apikey' as the username.

## `smtpPassword` (type: `string`):

SMTP login password. For Gmail, use an App Password (Google Account > Security > App Passwords). For SendGrid/Mailgun, use your API key.

## `useTls` (type: `boolean`):

Enable TLS encryption. Port 587 uses STARTTLS, port 465 uses direct SSL. Recommended: always keep enabled.

## Actor input object example

```json
{
  "to": "recipient@example.com",
  "subject": "Test Email from Apify",
  "smtpHost": "smtp.gmail.com",
  "smtpPort": 587,
  "useTls": true
}
```

# Actor output Schema

## `results` (type: `string`):

Dataset containing delivery confirmation for each email sent

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "to": "recipient@example.com",
    "subject": "Test Email from Apify",
    "smtpHost": "smtp.gmail.com",
    "smtpPort": 587,
    "useTls": true
};

// Run the Actor and wait for it to finish
const run = await client.actor("nimbryxo-studio/smtp-email-sender-for-workflow-notifications").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "to": "recipient@example.com",
    "subject": "Test Email from Apify",
    "smtpHost": "smtp.gmail.com",
    "smtpPort": 587,
    "useTls": True,
}

# Run the Actor and wait for it to finish
run = client.actor("nimbryxo-studio/smtp-email-sender-for-workflow-notifications").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "to": "recipient@example.com",
  "subject": "Test Email from Apify",
  "smtpHost": "smtp.gmail.com",
  "smtpPort": 587,
  "useTls": true
}' |
apify call nimbryxo-studio/smtp-email-sender-for-workflow-notifications --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,nimbryxo-studio/smtp-email-sender-for-workflow-notifications"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/LZLFcGSFyk5X30jn1/builds/mX5wE5AOnSOfsXi8M/openapi.json
