create repeating imap/pop3 import
Hello,
i read the docs and can’t find a helpful answer for this question.
Question:
How can i import mails with IMAP / POP3 every x minutes, instead of receiving them with SMTP?
Why:
SMTP needs a open port and a static IP address.
How:
my idea add a import command to the crontab
*/5 * * * * pilerimport -i imap.srv.com -u usr -p mypassword -r
Is that the way to go?
Imap with - r is possible or should i use POP3 ?
https://www.mailpiler.org/wiki/current:importing-emails
-r Remove imported emails
IMPORTANT! pilerimport doesn't change or delete the imported file, only reads it.
So -r is not working !?
Can you provide a working example ?
Thank you
Comments (7)
-
repo owner -
reporter IMPORTANT! pilerimport doesn't change or delete the imported file, only reads it.
does this statement refer to the pilerimport without -r ?
-
repo owner That statement is somewhat misleading, I’ve just removed it. So pilerimport removes the successfully processed (either stored, duplicate or discarded) file when using the -r option.
-
repo owner - changed status to resolved
-
reporter Example Cronjob
Fetch mails from journal@ every 5 minutes and remove them:
*/5 * * * * /usr/libexec/piler/imapfetch.py -s Imap.yourdomain.com -u journal@yourdomain.com -p yourpassword -r
i used the imapfetch.py from the master branch, with remove (-r) function
https://bitbucket.org/jsuto/piler/src/master/util/imapfetch.py -
repo owner Great. However, imapfetch.py only downloads the email, but you need to run pilerimport to process those emails.
Also there’s no guarantee that your simple cron job completes in 5 mins, I’d use a bash script to run both imapfetch.py and pilerimport, and add a mechanism, eg. flock to prevent concurrent runnings.
-
reporter */5 * * * * flock -n /tmp/piler_import.lock -c "cd /tmp && pilerimport -i Imap.yourdomain.com -u journal@yourdomain.com -p yourpassword -P 993 -r"
pilerimport is doing all, download, delete and process
thank you
- Log in to comment
Well, pop3 is a much simpler protocol. You may try using it, eg. pilerimport -K pop3.server.com -u user -p yourpassword -r
The -r option should work for pop3. Or you may try the imapfetch.py utility. Basically it only downloads (and optionally removes) emails from an imap mailbox, and then you may run pilerimport to process these emails.