1DELETEMAIL(1)               General Commands Manual              DELETEMAIL(1)
2
3
4

NAME

6       deletemail - remove old mail from server
7

SYNOPSIS

9       deletemail [-nqsuv[v]] [-f file]
10
11       deletemail -h | -V
12

DESCRIPTION

14       deletemail  is  a non-interactive tool for deleting mail which is older
15       than a configurable number of days from one or more IMAP mailboxes.  By
16       default,  mail  which  is  not marked as seen on the server will not be
17       deleted.  Currently, the IMAP4 and IMAP4rev1 protocols  are  supported,
18       optionally using SSL/TLS for secure IMAP connections.
19

OPTIONS

21       -f file
22              Use file instead of $HOME/.deletemailrc for configuration.
23
24       -h     Print a short description of all available options and exit.
25
26       -n     Mark  messages  as deleted on the server, but don't expunge them
27              (that is, omit the IMAP CLOSE command).  This might be useful in
28              order to test whether or not everything works as expected.  How‐
29              ever, please note that the “deleted” flags will not  be  revoked
30              by  deletemail,  so  these messages might be expunged by another
31              IMAP client accessing the mailbox.
32
33       -q     Quiet output, only error messages are printed.
34
35       -s     Don't use unique message IDs  in  IMAP  commands.   By  default,
36              deletemail  will use UIDs when issuing IMAP SEARCH or STORE com‐
37              mands, since UIDs are safer in case multiple  IMAP  clients  are
38              accessing the mailbox at the same time.  However, there are IMAP
39              servers which seem to have problems using UIDs.   Thus,  if  you
40              encounter  strange behaviour (like the server unexpectedly clos‐
41              ing the connection), this option might be helpful.
42
43       -u     Delete any message which is older than the configured number  of
44              days, no matter whether or not the message is marked as seen.
45
46       -V     Print version information and exit.
47
48       -v[v]  If  the  -v  option is used, all commands sent to the server and
49              all server responses will  be  printed  to  the  standard  error
50              stream.   If  -v is specified twice, (quite a lot of) additional
51              debug output will be produced.
52

CONFIGURATION FILE

54       By default, the configuration file $HOME/.deletemailrc  will  be  read.
55       Each  IMAP  account on which deletemail should operate is configured by
56       using the keyword ACCOUNT, followed by variable: value pairs specifying
57       the  account  settings;  one variable: value pair per line.  Apart from
58       that, the keyword GLOBAL, followed by variable: value pairs may option‐
59       ally  be  used  for specifying default settings.  If GLOBAL is used, it
60       must be declared prior to any ACCOUNT settings.  The  default  settings
61       will only take effect if they are not specified for a given ACCOUNT.
62
63       Configuration values may include all ASCII characters.  Empty lines and
64       the rest of a line after a “#” will be  ignored.   Whitespace  and  “#”
65       must  be escaped using a backslash if the value is not quoted with sin‐
66       gle or double quotes.  If the value is quoted, the quote sign  must  be
67       escaped  using a backslash.  A literal backslash must always be escaped
68       using another backslash.  If the last character of a configuration line
69       is a backslash, the following line will be appended prior to parsing.
70
71   Required Configuration Variables
72       The following configuration variables must be set, either by specifying
73       default settings using the keyword GLOBAL and/or by specifying them for
74       each ACCOUNT.
75
76       days: <integer>
77              The  number  of  days  that  messages should stay on the server.
78              Messages which are not older than specified  here  will  not  be
79              deleted.
80
81       host: <string>
82              The IMAP server name or IP address.
83
84       pass: <string>
85              The password for authentication on the server.
86
87       user: <string>
88              The username for authentication on the server.
89
90   Optional Configuration Variables
91       The  following configuration variables may be set, either by specifying
92       default settings using the keyword GLOBAL and/or by specifying them for
93       one or more ACCOUNTs.
94
95       expunge: yes|no
96              If  set  to  no, messages will still be marked as deleted on the
97              server, but they won't  be  expunged  by  deletemail.   However,
98              these  messages might be expunged by another IMAP client access‐
99              ing the mailbox.  This variable will be  overridden  by  the  -n
100              command line switch.  Default: yes.
101
102       folder: <string> [string...]
103              The  mailbox  name.   Multiple  folders may be specified using a
104              space delimited list.  Default: INBOX.
105
106       port: <integer>
107              The server port number.  Default: 993 for SSL  connections,  143
108              otherwise.
109
110       ssl: yes|no|starttls
111              Specifies  usage of SSL/TLS for secure IMAP connections.  If set
112              to yes, SSL on connect will be used; if set to starttls, the TLS
113              connection  will  be  initiated  using STARTTLS.  In both cases,
114              deletemail will exit with an error prior to  sending  any  login
115              information  if the server doesn't support the respective mecha‐
116              nism.   Default:  no.   This  variable  is  only  available   if
117              deletemail was built with SSL support.
118
119       unseen: yes|no
120              If  set  to  yes,  any message that is older than the configured
121              number of days will be deleted, no matter  whether  or  not  the
122              message is marked as seen.  If set to no, messages which are not
123              marked as seen will never be deleted.   This  variable  will  be
124              overridden by the -u command line switch.  Default: no.
125
126       use_uid: yes|no
127              If set to no, deletemail won't use unique message IDs when talk‐
128              ing to the IMAP server.  See the -s command line  switch  (which
129              will  override  the use_uid setting) for implications.  Default:
130              yes.
131

RETURN VALUE

133       Upon successful completion, deletemail returns 0.  If any sort of error
134       is encountered, deletemail returns a value other than 0.
135

EXAMPLES

137       Configure deletemail via the file $HOME/.deletemailrc, which could look
138       like this:
139
140              ACCOUNT # Toms INBOX on the ISPs IMAP server
141                host: imap.provider.com
142                user: tom
143                pass: h0lyPa55
144                days: 7  # delete mail if it's older than a week
145                ssl: yes # use SSL for secure IMAP connections
146
147       Test your configuration by creating verbose output  and  not  expunging
148       deleted messages on the server:
149
150              deletemail -nv
151
152       Run  deletemail  once  an  hour  (at twenty past) by using a crontab(5)
153       entry like the following:
154
155              20 * * * * /usr/local/bin/deletemail -q
156

ENVIRONMENT

158       HOME   If the configuration file is not specified on the command  line,
159              $HOME/.deletemailrc will be used.
160

FILES

162
163       $HOME/.deletemailrc   default configuration file
164

CAVEATS

166       For  SSL  connections, deletemail currently does not support any mecha‐
167       nism to prevent “man in the  middle”  attacks.   Future  releases  will
168       probably provide certificate and key fingerprint checking.
169
170       Apart  from  that,  on  systems that lack a useable random device (like
171       /dev/urandom), deletemail will try to  collect  some  random  data  for
172       seeding  OpenSSLs PRNG on it's own.  However, this is insecure.  Please
173       consider installing an entropy gathering daemon like EGD  or  PRNGD  if
174       your  system  doesn't  provide  a  useable random device (the output of
175       deletemail -vv will tell you whether or not that's the case).  See  the
176       OpenSSL manual page RAND_egd(3) for information on where to get and how
177       to install an entropy gathering daemon so  that  OpenSSL  will  use  it
178       automatically.
179

BUGS

181       The mailbox name may not include non-ASCII characters, since they won't
182       be encoded according to the IMAP standard when talking to  the  server.
183       IPv6 is not supported.
184
185       I'm sure there are more bugs, please let me know if you find them.
186

AUTHOR

188       Holger Weiss <holger@jhweiss.de>
189

SEE ALSO

191       fetchmail(1), crontab(1), crontab(5), cron(8), ssl(3), crypto(3)
192
193
194
195                                April 10, 2006                   DELETEMAIL(1)
Impressum