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

# SMTP

> Send email through MailGlyph using standard SMTP clients

MailGlyph includes an SMTP relay so you can send emails from apps and tools that support SMTP.

> [!WARNING]
>
> Your sender (`From`) domain must already be added and verified in your workspace before SMTP sends are accepted.
> See [Verifying domains](https://docs.mailglyph.com/guides/verifying-domains.md).

## SMTP credentials

Use these credentials in your SMTP client:

* **SMTP server**: `smtp-out.mailglyph.com`
* **Username**: `mailglyph`
* **Password**: any active secret API key (`sk_...`)
* **Port (STARTTLS)**: `587`
* **Port (SSL/TLS)**: `465`

## How to set it up

**1. Verify your sending domain**

Add and verify the domain you will use in the `From` address.

**2. Collect SMTP settings**

Copy SMTP host, ports, username, and a secret API key from your workspace.

**3. Configure your app or email client**

Set SMTP auth with username `mailglyph` and password = your secret API key.

**4. Send a test email**

Send a message from a verified sender address like `hello@yourdomain.com`.

## SMTP behavior and limits

* Authentication is required for every SMTP session.
* Sender domain must belong to your workspace and be verified.
* If you use a domain-scoped secret key, sender domains are restricted to that key's allowlist.
* Maximum recipients per message is `5`.
* Maximum message size is `10 MB`.
* Messages must include:
  * a valid sender
  * at least one recipient
  * a subject
  * body content (HTML or text)

Attachments are supported.

## Example (Node.js / Nodemailer)

```js theme={null}
import nodemailer from "nodemailer";

const transporter = nodemailer.createTransport({
  host: "smtp-out.mailglyph.com",
  port: 587,
  secure: false, // STARTTLS
  auth: {
    user: "mailglyph",
    pass: process.env.MAILGLYPH_SECRET_KEY,
  },
});

await transporter.sendMail({
  from: "Acme <hello@yourdomain.com>",
  to: "user@example.com",
  subject: "Test via MailGlyph SMTP",
  text: "Hello from SMTP",
});
```

## Example (Python / smtplib)

```python theme={null}
import smtplib
from email.mime.text import MIMEText

msg = MIMEText("Hello from SMTP")
msg["Subject"] = "Test via MailGlyph SMTP"
msg["From"] = "hello@yourdomain.com"
msg["To"] = "user@example.com"

with smtplib.SMTP("smtp-out.mailglyph.com", 587) as server:
    server.starttls()
    server.login("mailglyph", "YOUR_SECRET_API_KEY")
    server.send_message(msg)
```

## Example (Laravel)

Set your mailer to SMTP in `.env`:

```env theme={null}
MAIL_MAILER=smtp
MAIL_HOST=smtp-out.mailglyph.com
MAIL_PORT=587
MAIL_USERNAME=mailglyph
MAIL_PASSWORD=YOUR_SECRET_API_KEY
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=hello@yourdomain.com
MAIL_FROM_NAME="Acme"
```

Send a test email:

```php theme={null}
use Illuminate\Support\Facades\Mail;

Route::get('/mailglyph-test', function () {
    Mail::raw('Hello from MailGlyph SMTP', function ($message) {
        $message->to('user@example.com')
            ->subject('Test via MailGlyph SMTP');
    });

    return 'Email sent';
});
```

## Troubleshooting

* **`Invalid username`**: use `mailglyph` as username.
* **`Invalid API key`**: use an active secret key (`sk_...`), not a public key.
* **`Sender domain is not verified or not associated with your account`**:
  verify the sender domain in your current workspace and ensure it is allowed by the key scope.
* **TLS connection issues on port 465**:
  use port 587 with STARTTLS.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.