Here’s some instructions to be able to print from your ReMarkable. It in essence makes it so that your printer has an “email to print” capability and you just send from your remarkable to your printer email address.
Note: You’ll need a need gmail address and a dedicated computer to watch your inbox. (Like maybe a Raspberry Pi sitting around)
pip install imaplib2 pyzmail36
imaplib2 checks your mailbox. pyzmail36 handles attachments.
import imaplib
import email
import os
import subprocess
# ==== SETTINGS ====
EMAIL_USER = "YOUR_EMAIL_ADDRESS"
EMAIL_PASS = "YOUR_APP_PASSWORD_INCLUDE_SPACES" # Gmail App Password
IMAP_SERVER = "imap.gmail.com"
SAVE_DIR = "/tmp/email_prints"
PRINTER_NAME = "YOUR_PRINTER_NAME"
# Optional: Only accept emails from these senders
ALLOWED_SENDERS = {"[email protected]"} # Change this, or set to empty {} for no restriction
# Allowed file extensions
ALLOWED_EXT = {".pdf", ".txt", ".docx", ".png", ".jpg"}
# Make sure save dir exists
os.makedirs(SAVE_DIR, exist_ok=True)
def save_attachments(msg):
"""Save valid attachments to SAVE_DIR"""
attachments = []
for part in msg.walk():
if part.get_content_disposition() == 'attachment':
filename = part.get_filename()
if filename:
ext = os.path.splitext(filename)[1].lower()
if ext in ALLOWED_EXT:
filepath = os.path.join(SAVE_DIR, filename)
with open(filepath, "wb") as f:
f.write(part.get_payload(decode=True))
attachments.append(filepath)
return attachments
def print_file(filepath):
"""Send file to printer"""
print(f"Printing {filepath}...")
subprocess.run(["lp", "-d", PRINTER_NAME, filepath])
def check_mail():
"""Check Gmail inbox for new messages and print attachments"""
mail = imaplib.IMAP4_SSL(IMAP_SERVER)
mail.login(EMAIL_USER, EMAIL_PASS)
mail.select("inbox")
result, data = mail.search(None, '(UNSEEN)')
if result == "OK":
for num in data[0].split():
result, msg_data = mail.fetch(num, "(RFC822)")
if result != "OK":
continue
msg = email.message_from_bytes(msg_data[0][1])
# Check sender
from_addr = email.utils.parseaddr(msg["From"])[1]
if ALLOWED_SENDERS and from_addr not in ALLOWED_SENDERS:
print(f"Skipping email from {from_addr}")
continue
# Save and print attachments
attachments = save_attachments(msg)
for filepath in attachments:
print_file(filepath)
# Mark as read
mail.store(num, '+FLAGS', '\\\\Seen')
mail.logout()
if __name__ == "__main__":
check_mail()
crontab -e
* * * * * /usr/bin/python3 /home/yourusername/emailtoprint.py