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

# Send Outbound Email via SMTP with UGMail (Port 587)

> Connect to UGMail's SMTP server at mail.ugmail.co:587 with STARTTLS to send transactional email, app notifications, and outbound messages from any mailbox.

SMTP (Simple Mail Transfer Protocol) is the universal standard for sending email. Use UGMail's SMTP server to deliver transactional messages, application notifications, automated alerts, or any outbound email directly from your code or email client. Every mailbox provisioned through UGMail is SMTP-enabled the moment it is created.

## Connection settings

Configure your SMTP client or library with the following details:

| Setting  | Value                      |
| -------- | -------------------------- |
| Server   | `mail.ugmail.co`           |
| Port     | `587`                      |
| Security | STARTTLS                   |
| Username | Your mailbox email address |
| Password | Your mailbox password      |

<Tip>Always use port 587 with STARTTLS rather than port 25. Port 25 is blocked by most cloud providers and ISPs to prevent spam. STARTTLS on 587 upgrades the connection to encrypted transport before any credentials are sent.</Tip>

## Authentication

Use your mailbox's full email address as the username and the password you configured in the `secrets` field of the Management API as the password. For example, if your mailbox is `alice@example.com`, your SMTP username is `alice@example.com`.

<Tip>For programmatic access, treat the mailbox password as an app password. Generate a dedicated mailbox for each application or service so you can rotate credentials independently without affecting other senders.</Tip>

## Code examples

The examples below show how to send a message from `alice@example.com` to `bob@example.com`. Replace the credentials and addresses with your own.

<CodeGroup>
  ```python Python (smtplib) theme={null}
  import smtplib
  from email.mime.text import MIMEText

  smtp = smtplib.SMTP('mail.ugmail.co', 587)
  smtp.starttls()
  smtp.login('alice@example.com', 'SecurePassword123!')

  msg = MIMEText('Hello from UGMail!')
  msg['Subject'] = 'Test Email'
  msg['From'] = 'alice@example.com'
  msg['To'] = 'bob@example.com'

  smtp.sendmail('alice@example.com', ['bob@example.com'], msg.as_string())
  smtp.quit()
  ```

  ```javascript Node.js (nodemailer) theme={null}
  const nodemailer = require('nodemailer');

  const transporter = nodemailer.createTransport({
    host: 'mail.ugmail.co',
    port: 587,
    secure: false, // STARTTLS upgrades the connection after the handshake
    auth: {
      user: 'alice@example.com',
      pass: 'SecurePassword123!',
    },
  });

  async function sendMail() {
    const info = await transporter.sendMail({
      from: 'alice@example.com',
      to: 'bob@example.com',
      subject: 'Test Email',
      text: 'Hello from UGMail!',
    });

    console.log('Message sent:', info.messageId);
  }

  sendMail();
  ```

  ```bash curl theme={null}
  curl --url 'smtp://mail.ugmail.co:587' \
    --ssl-reqd \
    --mail-from 'alice@example.com' \
    --mail-rcpt 'bob@example.com' \
    --user 'alice@example.com:SecurePassword123!' \
    --upload-file - <<EOF
  From: alice@example.com
  To: bob@example.com
  Subject: Test Email

  Hello from UGMail!
  EOF
  ```
</CodeGroup>

## Troubleshooting

<Warning>If your messages are rejected with an authentication error, verify that the password matches exactly what you set in the `secrets` field of the Management API. Passwords are case-sensitive. If you've rotated the password via the API, update your application configuration to use the new value.</Warning>

| Symptom                          | Likely cause                        | Fix                                                                                         |
| -------------------------------- | ----------------------------------- | ------------------------------------------------------------------------------------------- |
| `Connection refused` on port 587 | Firewall blocking outbound port 587 | Open port 587 outbound, or contact your network administrator                               |
| `Authentication failed`          | Wrong username or password          | Confirm the username is the full email address and the password matches the `secrets` field |
| `STARTTLS required` error        | Client not initiating TLS           | Enable STARTTLS in your client settings                                                     |
| Messages land in spam            | Missing SPF/DKIM records            | Configure SPF and DKIM for your sending domain in the UGMail dashboard                      |
