/api/qmail/delete

DELETE

Permanently delete an email from the system.

DELETE /api/qmail/delete?email_id={email_id}

Description

The /api/qmail/delete endpoint permanently removes an email from the system. The email is identified by its 32-character hexadecimal GUID passed as the email_id query parameter.

Permanent Deletion Warning

This operation is irreversible. Once deleted, the email cannot be recovered. Consider moving emails to the trash folder first (using the move endpoint) to allow for recovery before permanent deletion.

Parameters

Parameter Type Required Description
email_id string Yes The unique email identifier. Must be a 32-character hexadecimal GUID string.

Response

Returns a JSON object confirming the deletion.

Response Properties

success boolean
Indicates whether the request was successful. true on success.
message string
A human-readable confirmation message. Returns "Email deleted" on success.
email_id string
The 32-character hex GUID of the email that was deleted.

Example Success Response

{
  "success": true,
  "message": "Email deleted",
  "email_id": "a1b2c3d4e5f67890a1b2c3d4e5f67890"
}

Error Responses

// 400 Bad Request - Missing email_id
{
  "success": false,
  "message": "Missing required parameter: email_id"
}

// 400 Bad Request - Invalid format
{
  "success": false,
  "message": "Invalid email_id format"
}

// 404 Not Found - Email does not exist
{
  "success": false,
  "message": "Failed to delete email"
}

Try It Out

Enter a 32-character hexadecimal email ID
http://localhost:8080/api/qmail/delete?email_id={email_id}
Warning

Executing this request will permanently delete the email. This action cannot be undone.

Examples

cURL

# Permanently delete an email by ID
curl -X DELETE "http://localhost:8080/api/qmail/delete?email_id=a1b2c3d4e5f67890a1b2c3d4e5f67890"

JavaScript (async/await)

const API_BASE = 'http://localhost:8080/api';
const emailId = 'a1b2c3d4e5f67890a1b2c3d4e5f67890';

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

        if (result.success) {
            console.log(`Email ${result.email_id} deleted successfully`);
            console.log(result.message);
        } else {
            console.error('Failed to delete email:', result.message);
        }

        return result;
    } catch (error) {
        console.error('Error deleting email:', error);
    }
}

deleteEmail(emailId);

Python

import requests

API_BASE = 'http://localhost:8080/api'
email_id = 'a1b2c3d4e5f67890a1b2c3d4e5f67890'

def delete_email(email_id):
    response = requests.delete(
        f'{API_BASE}/qmail/delete',
        params={'email_id': email_id}
    )
    result = response.json()

    if result.get('success'):
        print(f"Email {result['email_id']} deleted successfully")
        print(result['message'])
    else:
        print(f"Failed to delete email: {result.get('message')}")

    return result

delete_email(email_id)

Related Endpoints

/api/qmail/inbox

List emails from any folder to identify candidates for deletion.

/api/qmail/read

Read an email's full contents before deciding to delete it.