# 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>
