Script which connects to an IMAP mailbox and prints whatever arrives as PDF using a given CUPS printer.
- Set your parameters in
config.ini. - Launch in the background, via
screen, or define a systemd service.
keyword: A word that must be included in the subject for the script to process the email, preventing spam mails from being printed. AuThEnTICAtiOn yaydelete_mail: Whether the script should delete all emails in the mailbox after processing.
If using a remote host, ensure that CUPS accepts remote print jobs:
cupsctl --share-printersThis command allows printing on the local subnet. If it's on a remote subnet, use:
cupsctl --share-printers --remote-anyThen, set a particular printer to shared. Check the printer names:
root@jelito ~ $ lpstat
Xerox_WorkCentre_3025-34 root 1024 Sun 07 Jan 2024 01:31:51 PM CET
Basement_Brother_Printer root 0 Fri 03 Jan 2025 12:50:11 PM CETSet a particular printer to shared:
lpadmin -p Basement_Brother_Printer -o printer-is-shared=trueUse this CUPS printer name in the printer section of the config.ini.
The following will just list out printers on a given host, mailboxes in a given IMAP server and quit.
python3 mailprinter.py list