/api/qmail/trash

DELETE

Soft-delete an email by moving it to the trash folder.

DELETE /api/qmail/trash

Description

The DELETE /api/qmail/trash endpoint performs a soft delete by moving the specified email to the trash folder. The email is not permanently deleted and can be recovered by moving it back to another folder using /api/qmail/move.

Recoverable Operation

This endpoint performs a soft delete. The email is moved to trash and can be recovered by moving it back to another folder using /api/qmail/move. To permanently delete, use /api/qmail/delete-permanent after trashing.

Parameters

Send as query parameters or form-encoded body:

Parameter Type Required Description
email_id string Required The unique email identifier (32-character hexadecimal GUID).

Response

Returns a JSON object confirming the email was moved to trash.

Response Properties

success boolean
Indicates whether the operation completed successfully.
message string
"Email moved to trash"

Example Success Response

{
  "success": true,
  "message": "Email moved to trash"
}

Example Error Response (400 Bad Request)

{
  "success": false,
  "message": "Missing or invalid 'email_id' parameter (32 hex chars)"
}

Example Error Response (404 Not Found)

{
  "success": false,
  "message": "Email not found"
}

Try It Out

Enter a 32-character hexadecimal email ID

Examples

cURL

curl -X DELETE "http://localhost:8080/api/qmail/trash?email_id=a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6"

JavaScript (async/await)

const API_HOST = 'http://localhost:8080';

async function trashEmail(emailId) {
    try {
        const response = await fetch(
            `${API_HOST}/api/qmail/trash?email_id=${emailId}`,
            { method: 'DELETE' }
        );
        const result = await response.json();

        if (result.success) {
            console.log(result.message);
        } else {
            console.error('Error:', result.message);
        }
        return result;
    } catch (error) {
        console.error('Error trashing email:', error);
    }
}

trashEmail('a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6');

Python

import requests

API_HOST = 'http://localhost:8080'

def trash_email(email_id):
    response = requests.delete(
        f'{API_HOST}/api/qmail/trash',
        params={'email_id': email_id}
    )
    result = response.json()

    if result.get('success'):
        print(result['message'])
    else:
        print(f"Error: {result.get('message')}")

    return result

trash_email('a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6')

Related Endpoints

/api/qmail/delete-permanent

Permanently delete an email that is already in trash.

/api/qmail/move

Move an email to a different folder (can recover from trash).

/api/qmail/inbox

List emails in a folder.