Trash Mail
Trash Mail is a service that allows you to recover emails that have been deleted from your inbox.
By default the node is removed from the trash after 30 days. You can change this time with this function app.updateSettings().
Get the client
import { getSecrecyClient } from '@secrecy/lib';
// Get the client
const client = getSecrecyClient('prod');
deletedMails()
Get all deleted mails.
import { MailType } from '@secrecy/lib';
const response = await client.mail.deletedMails({
mailType: MailType.received,
});
if (!response) {
throw new Error(`Error`);
}
switch (response.__typename) {
case 'ErrorAccessDenied':
throw new Error(`Access Denied`);
case 'SuccessResponse': {
const deletedMails = response.data;
// Do something with the deleted mails
}
}
Parameters
Parameter | Description | Type | Default |
---|---|---|---|
mailType | The type of the mail. Either received or sent . | MailType | required |
recover()
Recover an email from the trash.
const response = await client.mail.recover({
mailId: 'MAIL_ID',
});
if (!response) {
throw new Error(`Error`);
}
switch (response.__typename) {
case 'ErrorAccessDenied':
throw new Error(`Access Denied`);
case 'ErrorBasic':
throw new Error(`Error Basic`);
case 'SuccessResponse': {
const boolean = response.data;
// Do something with the boolean
}
}
deleteTrash()
Definitively delete mails by mail id.
const response = await client.mail.deleteTrash({
ids: ['TRASH_MAIL_ID_1', 'TRASH_MAIL_ID_2'],
});
if (!response) {
throw new Error(`Error`);
}
switch (response.__typename) {
case 'ErrorAccessDenied':
throw new Error(`Access Denied`);
case 'SuccessResponse': {
const boolean = response.data;
// Do something with the boolean
}
}
emptyTrash()
Definitively delete all mails.
const response = await client.mail.emptyTrash();
if (!response) {
throw new Error(`Error`);
}
switch (response.__typename) {
case 'ErrorAccessDenied':
throw new Error(`Access Denied`);
case 'SuccessResponse': {
const boolean = response.data;
// Do something with the boolean
}
}