> ## Documentation Index
> Fetch the complete documentation index at: https://docs.spojit.com/llms.txt
> Use this file to discover all available pages before exploring further.

# SMTP Email

> Send emails via any SMTP server (Gmail, Outlook, self-hosted, etc.).

The SMTP Email connector lets your workflows send emails through any SMTP-compatible mail server. Works with Gmail, Microsoft 365, Amazon SES, SendGrid, Mailgun, and any self-hosted SMTP server.

<Tip>
  If you just need to send a quick notification email without setting up an external service, use the built-in [Send Email node](/workflow-editor/nodes/send-email) instead; it sends from Spojit with no connection required.
</Tip>

<Snippet file="connection-note.mdx" />

## Connection setup

<Steps>
  <Step title="Gather your SMTP credentials">
    You'll need the following from your email provider:

    * **SMTP Host** (e.g., `smtp.gmail.com`)
    * **Port** (typically `587` for STARTTLS or `465` for SSL)
    * **Username** (usually your email address)
    * **Password** (your email password or app-specific password)
  </Step>

  <Step title="Add the connection in Spojit">
    Go to **Connections** in Spojit, click **Add Connection**, select **SMTP Email**, and enter:

    * **SMTP Host**: Your mail server hostname
    * **Port**: SMTP port number
    * **Username**: Your SMTP username
    * **Password**: Your SMTP password
    * **Use SSL/TLS** (optional): Enable for port 465. Auto-detected if left off.
    * **Default From Address** (optional): A default sender address (e.g., `Team <hello@yourdomain.com>`) used when `from` is not specified in the tool parameters
  </Step>
</Steps>

<Tip>
  **Gmail**: You must use an [App Password](https://support.google.com/accounts/answer/185833) instead of your regular password. Enable 2-Step Verification first, then generate an App Password.
</Tip>

<Tip>
  **Microsoft 365**: SMTP AUTH must be enabled for the mailbox. An admin can enable it in the Microsoft 365 admin center under **Active users → Mail → Manage email apps**.
</Tip>

### Common SMTP settings

| Provider                | Host                                 | Port | Notes                                          |
| ----------------------- | ------------------------------------ | ---- | ---------------------------------------------- |
| Gmail                   | `smtp.gmail.com`                     | 587  | Requires App Password                          |
| Outlook / Microsoft 365 | `smtp.office365.com`                 | 587  | Enable SMTP AUTH                               |
| Amazon SES              | `email-smtp.us-east-1.amazonaws.com` | 587  | Use SMTP credentials (not AWS keys)            |
| SendGrid                | `smtp.sendgrid.net`                  | 587  | Username is `apikey`, password is your API key |
| Mailgun                 | `smtp.mailgun.org`                   | 587  | Use domain-specific SMTP credentials           |

## Tools

<AccordionGroup>
  <Accordion title="send-email: Send an email">
    <ParamField body="from" type="string">
      Sender address (e.g., `Team <hello@yourdomain.com>`). Falls back to the connection's default from address.
    </ParamField>

    <ParamField body="to" type="string | string[]" required>
      Recipient email address(es).
    </ParamField>

    <ParamField body="subject" type="string" required>
      Email subject line.
    </ParamField>

    <ParamField body="html" type="string">
      HTML email body.
    </ParamField>

    <ParamField body="text" type="string">
      Plain text email body.
    </ParamField>

    <ParamField body="cc" type="string | string[]">
      CC recipient(s).
    </ParamField>

    <ParamField body="bcc" type="string | string[]">
      BCC recipient(s).
    </ParamField>

    <ParamField body="replyTo" type="string">
      Reply-to address.
    </ParamField>

    <ParamField body="attachments" type="object[]">
      File attachments. Each item is an object with a `filename` and base64-encoded `content`. The content type is inferred from the filename extension.

      In a workflow, map `content` to an upstream output that already produces base64-encoded bytes (e.g. a file downloaded over HTTP/FTP, or a document produced by another step).
    </ParamField>

    **Example request:**

    ```json theme={null}
    {
      "from": "Orders <orders@mystore.com>",
      "to": ["customer@example.com"],
      "subject": "Your order has shipped!",
      "html": "<h1>Order Shipped</h1><p>Your order #1234 has been shipped and is on its way.</p><p>Tracking: <a href='https://track.example.com/ABC123'>ABC123</a></p>",
      "cc": ["warehouse@mystore.com"],
      "replyTo": "support@mystore.com",
      "attachments": [
        { "filename": "invoice-1234.pdf", "content": "JVBERi0xLjQKJ..." }
      ]
    }
    ```

    **Example response:**

    ```json theme={null}
    {
      "success": true,
      "data": {
        "messageId": "<d2e8c1f3-4a5b-6c7d-8e9f-0a1b2c3d4e5f@mystore.com>",
        "accepted": ["customer@example.com", "warehouse@mystore.com"],
        "rejected": [],
        "response": "250 2.0.0 OK"
      }
    }
    ```
  </Accordion>

  <Accordion title="verify-connection: Test SMTP connection">
    Verifies that the SMTP server is reachable and the credentials are valid without sending an email. No parameters required.

    **Example response:**

    ```json theme={null}
    {
      "success": true,
      "data": {
        "message": "SMTP connection verified successfully"
      }
    }
    ```
  </Accordion>
</AccordionGroup>
