1. Home
  2. Email
  3. How to Use archivemail

How to Use archivemail

Shared

Introduction

The archivemail utility is used to archive and compress email, and can be used by all Shared Hosting account types.

In its default form, archivemail will move messages older than a specified number of days to a compressed archive file to download from your server. You can also use archivemail to simply delete messages.

Syntax

The syntax for the archivemail command is:

archivemail [options] {mailbox}

Options

There are many options for archivemail. To see them all, just run the archivemail by itself with no arguments.

Some of the most common options are below.

The following two options let you specify the date before which to archive messages. You can use one option or the other, but not both:

-d NUMBER

For example:

-d 365 {mailbox} will archive messages older than 365 days (one year).

or

-D DATE

For example:

-D 2005-03-11 will archive messages that predate March 3rd, 2005.

Note the acceptable formats for dates. You may use ISO format (YEAR-MM-DD) or Internet format: DD Mon YYYY

-n

-n will do a "dry run" of the archivemail command, showing what would have happened if you had done the command "for real". This can be useful when learning the command or when using the command just to get info about your mailbox.

Using the -n command before using archivemail in a delete capacity can also help you avoid doing something disastrous.

-u

This will skip unread messages.

--delete
Warning

This can have disastrous effects. Please be absolutely certain you know what you are doing before using archivemail to delete mail. Deletion is permanent. We are unable to restore permanently deleted files.

This option will cause archivemail to operate in a deleting, rather than archiving, capacity. Messages will be permanently deleted and will not be eligible for restoration.

Mailbox Format

The last part of the archivemail is the {mailbox} component.

You'll need some information specific to your mailbox:

  • The email address associated with the mailbox. For example, this might be [email protected].
  • The password for the mailbox. Let's use the fictional password P7qxZnM4 for our examples.
  • Your email server. This is typically username.mail.pairserver.com, substituting your Pair Networks account username. If you're unsure, check out our article on setting up an email reader.
  • The name of the mailbox itself. To archive your main mailbox, you'll typically use inbox. You can specify other custom mailboxes you've made or mailboxes like trash and spam. We'll use inbox for our examples.

You'll also need to specify a protocol. In many cases, this will be imaps://

Putting it all together

To run the archivemail command on [email protected]'s inbox, with password P7qxZnM4, on mail server exampleguy.mail.pairserver.com you'd enter the following as the {mailbox} argument:

imaps://[email protected]:[email protected]/inbox

A Warning About /usr/tmp

When running archivemail it makes use of /usr/tmp on the server it is being run from. When trying to archive too many messages at once, you may cause /usr/tmp to fill up and the command may fail. If this happens, consider using the -d option to set a threshold, starting with very old messages, and then progressing through to new messages in more manageable 365- or 180-day chunks.

Examples

Our examples will use the fictional mailbox described above.

Let's take a simple archive of last year's mail (and earlier, if any):

archivemail -D 2016-01-01 imaps://[email protected]:[email protected]/inbox

Let's check how much space we're using up by hoarding messages that are over 30 days old:

archivemail -n -d 30 imaps://[email protected]:[email protected]/inbox

Having taken the time to consider the consequences of permanent deletion, let's clear up valuable disk space on our account by getting rid of old spam messages:

archivemail --delete imaps://[email protected]:[email protected]/spam
Updated on February 27, 2020

Was this article helpful?

Related Articles

Need Support?
Can't find the answer you're looking for?
Contact Support