# SMTP

## Overview

It is possible to send MMS messages via SMTP using the MM4 services instead of the HTTP API.

## Authentication

MM4 servers support PLAIN and LOGIN AUTH mechanism.

Use the provided SMPP system\_id as the username, and the API Key as the password.

System IDs are normally 15 characters in length

## Available MM4 Endpoints

**TCP**

* `mmsc.tsgglobal.world:2525`

**TLS/SSL**

* `mmsc.tsgglobal.world:2465`

It is recommended to utilize the TLS port when capable. TLS supports versions 1.1 and 1.2.

## MM4 Commands

* `AUTH` - Mandatory
* `DATA` - Mandatory
* `EHLO` - Mandatory
* `HELO` - Available
* `MAIL` - Mandatory
* `NOOP` - Available, use to test if the connection is working
* `QUIT` - Available, optional, closing the connection also works
* `RCPT` - Mandatory
* `RSET` - Available
* `STARTTLS` - Disabled, use the TLS port instead
* `VRFY` - Unimplemented, and would be disabled

## MM4 Exchange Example

All lines must end with a `CRLF`. Some data has been omitted for brevity.

Note, arrows `> <` have been included in the example to denote origin of message.

* `>` Is a response from the server
* `<` Is input from the client

```
#
< NOOP
> 250 OK
< EHLO your_hostname
> MM4 server babble
< AUTH LOGIN
> 334 VXNlcm5hbWU6
< base64-encoded-system-id
> 334 UGFzc3dvcmQ6
< base64-encoded-api-key
> 235 Authentication successful
< MAIL FROM:<E164-number@hostname>
> 250 Sender OK
< RCPT TO:<E164-number@hostname>
> 250 Recipient OK
< DATA
> 354 enter mail, end with line containing only '.'
< your-mms-content-here
< .
> 250 queued as <message-id>
< QUIT
> 221 BYE
```

Note the order of the commands:

* AUTH must be used before MAIL and RCPT.
* RCPT can only be used after a MAIL command.
* DATA can only be used after a MAIL and RCPT commands.
* QUIT, NOOP can be used at anytime (except while entering mail.)

Failure to do so will result in various errors

```
#
# AUTH before HELO
503 ERROR: send EHLO first

# RCPT or MAIL before EHLO
503 ERROR: send EHLO or HELO first

# RCPT before MAIL
503 ERROR: send MAIL first

# DATA before MAIL
503 ERROR: need MAIL command

# DATA before RCPT
503 ERROR: need RCPT command
```

<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tsgglobal.com/api-reference/programmable-mms/smtp.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
