# Sending errors

Source: https://developer.nylas.com/docs/v3/email/sending-errors/

Sometimes, delivery of messages might fail if the user's email gateway rejects the message. This can happen for a number of reasons, including illegal attachment data, bad credentials, or rate-limiting.

If the email essage is submitted successfully, the server responds with a [`200 OK` HTTP response](/docs/api/errors/200-response/). If the message is not submitted, the server responds with an [error code](#nylas-error-codes).

> **Warn:** 
> **If any participant email addresses contain non-ASCII characters (for example, characters with accents or other diacritics), message delivery fails**. When this happens, Nylas returns a `402` error with the following message: "Sending to at least one recipient failed."

## Nylas error codes

The following table describes the error codes you might encounter when sending messages with Nylas.

| Status code | Type                | Description                                                                                                                                                                                                                    |
| ----------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `400`       | Bad request         | Your request was not formed properly, or contains an invalid parameter. The most common cause is invalid JSON.                                                                                                                 |
| `402`       | Message rejected    | The provider rejected the message because of its content or recipients. If the error includes "Sending to at least one recipient failed", it means that your message might have been delivered to only a subset of recipients. |
| `403`       | Unauthorized        | The server was not able to authenticate with the provider. Re-authenticate the user and try again.                                                                                                                             |
| `422`       | Mail provider error | An error occurred while the provider was sending the message. See the `server_error` parameter in the response JSON for more information.                                                                                      |
| `429`       | Quota exceeded      | The user has exceeded their provider's sending quota. There is no reliable way to determine these limits. Wait and try again later.                                                                                            |

| `429` | Account throttled | The account is in a throttled state and the mail server has asked Nylas to temporarily stop making requests. Wait and try again later. |
| `429` | Nylas API rate limit | You made too many requests to the Nylas API too quickly. Wait and try again later. For more information, see the [Rate limiting documentation](/docs/dev-guide/best-practices/rate-limits/). |
| `503` | Service unavailable | Nylas encountered an error while connected to the provider. Wait and try again later. |

For more information about errors and status codes, see [Nylas API responses, errors, and HTTP status codes](/docs/api/errors/).

### Nylas error responses

When you receive an error from Nylas, it includes a JSON payload with information about the specific error.

| Parameter      | Type   | Description                                                        |
| -------------- | ------ | ------------------------------------------------------------------ |
| `type`         | string | The type of error encountered.                                     |
| `message`      | string | A brief, human-readable description of the error.                  |
| `server_error` | string | (Optional) The original error returned by the user's email server. |

## Microsoft sending errors

Sometimes, you might receive a `120` error from Microsoft when attempting to send a message, similar to the following example:

> 120 MailSubmissionFailed The server failed to submit the message for delivery.

This is usually because you're trying to send a message using an email address other than the one you authenticated to Nylas (for example, if you authenticated using `nylas@example.com`, but you try to send a message from `swag@example.com`). When this happens, Nylas returns a `422` error with the following message: "Message delivery submission failed." It might also return a `429` error.

Follow these steps to troubleshoot the error:

1. Check the email account you're trying to send the message with, and verify that it's the same as the account you authenticated to Nylas.
2. Try to send the message again with exponential backoff.
3. Confirm that the Exchange server hasn't quarantined Nylas' dummy devices. See [Checking for quarantined EAS devices](/docs/unlisted/microsoft/quarantined-eas-devices/).
4. Confirm that your Microsoft 365 settings match [our recommended settings](/docs/provider-guides/microsoft/microsoft-365-settings/).

If these troubleshooting steps don't fix the error, you might be encountering a more complex issue that occurs on a small number of hosted Exchange and Microsoft 365 servers. For further troubleshooting, contact your email administrator or provider.

## Related resources

- [Diagnose email deliverability from the CLI](https://cli.nylas.com/guides/email-deliverability-cli) — check SPF, DKIM, and DMARC records from the terminal to troubleshoot delivery failures