Skip to Content
MailerSend
Account

SMTP Users

Easily manage SMTP users with MailerSend's API. Add, update, delete and retrieve a list of SMTP users in your account.

Get a list of SMTP users

Retrieve information about account SMTP users with this GET request:

GET https://api.mailersend.com/v1/domains/{domain_id}/smtp-users

Request parameters

URL parameterTypeRequiredLimitationsDetails
domain_idstringyes
Query ParameterTypeRequiredLimitationsDetails
limitintnoMin: 10, Max: 100Default: 25
pageintnoMin: 1
use MailerSend\MailerSend;

$mailersend = new MailerSend(['api_key' => 'key']);

$mailersend->smtpUser->getAll('domain-id', 25);

More examples

Responses

Valid

Response Code: 200 OK
Response Headers:
	content-type: application/json
{
  "data": [
    {
      "id": "0wkg2zj19ovx5py7",
      "name": "Support SMTP",
      "username": "MS_bGQ0nV@mailerlite.com",
      "enabled": true,
      "accessed_at": null,
      "server": "smtp.mailersend.net",
      "port": "587 or 2525",
      "domain": "7nxe3yjmeq28vp0k",
      "created_at": "2024-02-20T09:39:44.000000Z"
    }
  ],
  "links": {
    "first": "https://api.mailersend.com/v1/domains/7nxe3yjmeq28vp0k/smtp-users?page=1",
    "last": null,
    "prev": null,
    "next": null
  },
  "meta": {
    "current_page": 1,
    "current_page_url": "https://api.mailersend.com/v1/domains/7nxe3yjmeq28vp0k/smtp-users?page=1",
    "from": 1,
    "path": "https://api.mailersend.com/v1/domains/7nxe3yjmeq28vp0k/smtp-users",
    "per_page": 25,
    "to": 1
  }
}

Error

Response Code: 404 Not Found

Get a single SMTP user

If you want to retrieve a single account SMTP user, use this GET request:

GET https://api.mailersend.com/v1/domains/{domain_id}/smtp-users/{smtp_user_id}

Request parameters

URL parameterTypeRequiredLimitationsDetails
domain_idstringyes
smtp_user_idstringyes
use MailerSend\MailerSend;

$mailersend = new MailerSend(['api_key' => 'key']);

$mailersend->smtpUser->find('domain-id', 'smtp-user-id');

More examples

Responses

Valid

Response Code: 200 OK
Response Headers:
	content-type: application/json
{
  "data": {
    "id": "0wkg2zj19ovx5py7",
    "name": "Support SMTP",
    "username": "MS_bGQ0nV@mailerlite.com",
    "enabled": true,
    "accessed_at": null,
    "server": "smtp.mailersend.net",
    "port": "587 or 2525",
    "domain": "7nxe3yjmeq28vp0k",
    "created_at": "2024-02-20T09:39:44.000000Z"
  }
}

Error

Response Code: 404 Not Found

Add SMTP user

If you want to add a SMTP user to your domain, use this POST request:

POST https://api.mailersend.com/v1/domains/{domain_id}/smtp-users

Request parameters

URL parameterTypeRequiredLimitationsDetails
domain_idstringyes

Request Parameters

JSON parameters are provided in dot notation

JSON ParameterTypeRequiredLimitationsDetails
namestringyesMax 50 characters
enabledbooleanno
use MailerSend\MailerSend;
use MailerSend\Helpers\Builder\SmtpUserParams;

$mailersend = new MailerSend(['api_key' => 'key']);

$mailersend->smtpUser->create(
    'domain-id',
    (new SmtpUserParams('SMTP User Name'))
        ->setEnabled(true)
);

More examples

Responses

Response KeyTypeDetails
dataobjectSMTP user object created.

The password is returned only once, in the response to this create request. It is stored as a hash and cannot be retrieved again afterwards, so make sure to save it securely. If it is lost, delete the SMTP user and create a new one.

Valid

Response Code: 201 CREATED
Response Headers:
	content-type: application/json
{
  "data": {
    "id": "480xl1qpeorzeg65",
    "name": "Support",
    "username": "MS_8PerdM@mailerlite.com",
    "enabled": true,
    "accessed_at": null,
    "server": "smtp.mailersend.net",
    "port": "587 or 2525",
    "domain": "7nxe3yjmeq28vp0k",
    "created_at": "2024-02-20T09:39:44.000000Z",
    "password": "mssp.G7hR2kQ9vN4pL8xW"
  }
}

Invalid

Response Code: 422 Unprocessable Entity

See - Validation errors

Update SMTP user

If you want to update the information of an existing SMTP user, use this PUT request:

PUT https://api.mailersend.com/v1/domains/{domain_id}/smtp-users/{smtp_user_id}

Request Parameters

URL parameterTypeRequiredLimitationsDetails
domain_idstringyes
smtp_user_idstringyes

JSON parameters are provided in dot notation

JSON ParameterTypeRequiredLimitationsDetails
namestringnoMax 50 characters
enabledbooleanno
use MailerSend\MailerSend;
use MailerSend\Helpers\Builder\SmtpUserParams;

$mailersend = new MailerSend(['api_key' => 'key']);

$mailersend->smtpUser->update(
    'domain-id',
    'smtp-user-id',
    (new SmtpUserParams('Updated SMTP User Name'))
        ->setEnabled(false)
);

More examples

Responses

Response KeyTypeDetails
dataobjectSMTP user object updated.

Valid

Response Code: 200 OK
Response Headers:
	content-type: application/json
{
  "data": {
    "id": "0z76k5jg0o3yeg2d",
    "name": "Support SMTP",
    "username": "MS_9sjABw@testing.com",
    "enabled": false,
    "accessed_at": null,
    "server": "smtp.mailersend.net",
    "port": "587 or 2525",
    "domain": "04mknvjymj87xp62",
    "created_at": "2024-02-20T09:39:44.000000Z"
  }
}

Invalid

Response Code: 422 Unprocessable Entity

See - Validation errors

Delete SMTP user

If you want to remove SMTP user, use this DELETE request:

DELETE https://api.mailersend.com/v1/domains/{domain_id}/smtp-users/{smtp_user_id}

Request parameters

URL parameterTypeRequiredLimitationsDetails
domain_idstringyes
smtp_user_idstringyes
use MailerSend\MailerSend;

$mailersend = new MailerSend(['api_key' => 'key']);

$mailersend->smtpUser->delete('domain-id', 'smtp-user-id');

More examples

Responses

Valid

Response Code: 204 OK

Error

Response Code: 404 Not Found

On this page