I use fetchmail with imap protocol to upload emails from a mail server, and pipe them in procmail. I do this with the following command:
fetchmail -f /home/$USER/.fetchmailrc --ssl -t 100 -d 240 -s -m "/usr/bin/procmail /home/$USER/.procmailrc "
The .fetchmailrc is as follows:
poll imap.my_email_server.com protocol IMAP
user "user@email_server.com" with password "myPassword" is "user@email_server.com" here keep
The .procmailrc is the following :
:0:
* ^Subject: someSubject
{
:0 c
| $BIN/parse_email
:0 c
$HOME/posnav
:0
/dev/null
}
Everything works fine but how can i make the last command (here I push the email to /dev/null just to show the purpose) delete the email on the server from where I have fetched the emails ?
If you want to delete the mail on the server, you have to tell fetchmail to do that.
But, you explicitly told fetchmail to keep the message on the server by including the keyword "keep" in the run control file.
Change it to "no keep":