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

# Test Email Locally with Mailpit in Bearsampp

> Capture outgoing emails from your local PHP app with Mailpit in Bearsampp. View all sent messages in a web UI instead of delivering them to real inboxes.

Mailpit is a local email testing tool bundled with Bearsampp. Instead of delivering emails to real inboxes, it intercepts all outgoing SMTP messages and displays them in a web-based UI. This lets you test registration emails, password resets, notifications, and any other transactional email your application sends — without ever leaving your local machine or risking sending test messages to real users.

## How it works

Mailpit runs as a Windows service that listens on an SMTP port. When your PHP application (or any other local application) sends an email to that port, Mailpit captures it and stores it in an in-memory inbox. You can then open the Mailpit web UI to read the captured messages, inspect headers, and check HTML rendering.

## Default settings

| Property     | Value                                     |
| ------------ | ----------------------------------------- |
| SMTP port    | 1025                                      |
| Web UI       | Accessible via tray → Mailpit → Localhost |
| Service name | `bearsamppmailpit`                        |

## Configuring your application

Point your application's mail settings to Mailpit's SMTP port. Do not use port 25 — use 1025 (or whichever port you have configured in Bearsampp).

**For Laravel or Symfony projects**, update your `.env` file:

```env theme={null}
MAIL_MAILER=smtp
MAIL_HOST=localhost
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
```

**For PHP's built-in `mail()` function**, configure `php.ini` to use the SMTP relay:

```ini theme={null}
[mail function]
SMTP = localhost
smtp_port = 1025
```

You can open `php.ini` from the tray menu (**PHP** → **Edit php.ini**), make the changes, and restart Apache.

## Viewing captured emails

<Steps>
  <Step title="Make sure Mailpit is running">
    Right-click the tray icon → **Mailpit** → **Start service** if the service is not already active.
  </Step>

  <Step title="Send a test email from your app">
    Trigger an email from your application — for example, submit a registration form or a password reset request.
  </Step>

  <Step title="Open the Mailpit web UI">
    Right-click the tray icon → **Mailpit** → **Localhost**. The Mailpit inbox opens in your browser showing all captured messages.
  </Step>
</Steps>

<Note>
  Mailpit stores messages in memory. All captured emails are lost when the Mailpit service restarts. If you need to preserve a message, copy its content from the web UI before stopping the service.
</Note>

## Tray menu options

Right-click the tray icon → **Mailpit** to access:

<CardGroup cols={2}>
  <Card title="Start / Stop service" icon="power-off">
    Start or stop the Mailpit Windows service.
  </Card>

  <Card title="Change port" icon="network-wired">
    Switch Mailpit's SMTP port to a different value. Remember to update your application's mail config to match.
  </Card>

  <Card title="Localhost" icon="envelope">
    Open the Mailpit web UI in your browser to view captured messages.
  </Card>

  <Card title="Logs" icon="file-lines">
    Open the Mailpit log file to diagnose connection or startup issues.
  </Card>
</CardGroup>

## Service details

| Property          | Value              |
| ----------------- | ------------------ |
| Service name      | `bearsamppmailpit` |
| Default SMTP port | 1025               |
| Log file          | `logs/mailpit.log` |

<Tip>
  Mailpit also exposes an API for inspecting and deleting messages programmatically. This is useful for automated testing — your test suite can send emails and then assert their contents via the Mailpit API.
</Tip>
