---
title: SendTestMail2
slug: campaign/docs/sendtestmail2
docTags: 
createdAt: 2026-07-02T19:01:46.737Z
---

Fetch the complete documentation index at: [https://docs.developers.optimizely.com/optimizely-campaign/llms.txt](https://docs.developers.optimizely.com/optimizely-campaign/llms.txt). Use this file to discover all available pages before exploring further. Append .md to any documentation page URL to get its markdown version.

# sendTestMail2

Sends a test email to a recipient in Optimizely Campaign.

All mailing types and mailings in any status can be sent with this method.

:::hint{type="info"}
**Note**
The actual mail is sent asynchronously. That means that you should not delete the recipient immediately after calling this method.
:::

**Type**: int

**Parameters**

| Name            | Type   | Value                                                                                                                                                                                                                                                                                                                                                                                 |
| --------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| sessionId       | String | ID of the session                                                                                                                                                                                                                                                                                                                                                                     |
| mailingId       | long   | ID of the mailing                                                                                                                                                                                                                                                                                                                                                                     |
| mimeType        | String | MIME type of the test email<br />Following values can be used:<br />- Empty string (the MIME type of the mailing is used)<br />- text/plain (the mailing must use either the same MIME type or the MIME type multipart/alternative)<br />- text/html (the mailing must use either the same MIME type or the MIME type multipart/alternative)<br />- The same MIME type as the mailing |
| recipientListId | long   | ID of the recipient list<br />Must be a test recipient list and needs not to be configured for the given mailing.                                                                                                                                                                                                                                                                     |
| recipientId     | String | ID of the recipient<br />Must match the target group and not be unsubscribed or blocked.                                                                                                                                                                                                                                                                                              |

**Return values**

- 0: if the mail has been spooled
- 1: if the recipient is blocked
- 2: if the recipient is unsubscribed
- 3: if the recipient was not found
- 4: if the recipient list is invalid
- 5: if the recipient is blocked by the mailing's target group
- 6: if the recipient has caused too many bounces

**Code structure**

```java
int sendTestMail2(String sessoinId, long mailingId, String mimeType, long recipientListId, String recipientId)
```
