How to send photos to your Raspberry Pi digital photo frame via email - 2022 Update 2

How to send photos to your Raspberry Pi digital photo frame via email – 2022 Update

Do you want to email a picture from your phone to your digital picture frame? And allow friends & family to do the same?

In the past, my recommendation, based on Gmail, was described here.

However, I recently received an email from blog reader Daniel telling me that Google would stop allowing email access by “less secure apps” end of May 2022. Unfortunately, a Raspberry Pi Python script apparently qualifies as a “less secure app” and consequently, my proposed solution will likely not work any longer past this date.

But Daniel was kind enough to identify a solution that I have just tested and it works brilliantly.

Sending photos to your frame

First, a bit of background.

Regularly adding images to the collection on your digital picture frame is a crucial ingredient to enjoying the experience every day a bit more.

I have described a solution to share your digital picture frame image folder with family & friends using Resilio Sync. But sometimes even this is too much hassle, and you want an even simpler solution.

This is why it is helpful to have alternative ways to add images that are both fully automated and require no maintenance.

One approach is to send one or several images via email. This can be a dedicated email account or your normal one. I would, however, recommend a dedicated email account.

The emails have to be marked with a secret subject line, and only emails with this “password” are scanned and processed. The photos will then be downloaded and added to your frame – without you having to do a thing.

Following this scan, all emails are deleted, except those that did not have the matching subject line.

The following instructions assume that you have read the article “How to set up your Raspberry Pi for your digital picture frame“.

The attachment-downloader package

Thanks to James Ridgway and his fantastic solution, we now have an alternative when the Gmail changes happen.

For this solution to work, most email accounts should be fine, well, except for Gmail. Please email me if you have found other email providers where it doesn’t work. I tested it with WEB.DE, a German email provider.

The advantage of James’ solution is that it’s even easier to install than my previous script. It’s all described on his Github page but since I know that some of you may be a bit overwhelmed by the GitHub style, I’ll break it down for you.

The following instructions assume that you are ssh connected to your Raspberry Pi from another computer through Terminal.

To install the attachment-downloader package type:

$ pip install attachment-downloader

The script will install a number of packages and finish with a message similar to this:

[...]
Installing collected packages: imbox, assertpy, iso8601, pytz, python-dateutil, iniconfig, py, typing-extensions, zipp, importlib-metadata, pluggy, tomli, pyparsing, packaging, attrs, pytest, platformdirs, toml, wrapt, lazy-object-proxy, typed-ast, astroid, pylint, MarkupSafe, jinja2, coverage, pytest-cov, attachment-downloader
  The scripts py.test and pytest are installed in '/home/pi/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  The scripts epylint, pylint, pyreverse and symilar are installed in '/home/pi/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  The scripts coverage, coverage-3.7 and coverage3 are installed in '/home/pi/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed MarkupSafe-2.1.1 assertpy-1.1 astroid-2.9.3 attachment-downloader-1.2.2 attrs-21.4.0 coverage-6.3.2 imbox-0.9.8 importlib-metadata-4.11.3 iniconfig-1.1.1 iso8601-1.0.2 jinja2-3.0.3 lazy-object-proxy-1.7.1 packaging-21.3 platformdirs-2.5.1 pluggy-1.0.0 py-1.11.0 pylint-2.12.2 pyparsing-3.0.7 pytest-7.0.1 pytest-cov-3.0.0 python-dateutil-2.8.2 pytz-2021.3 toml-0.10.2 tomli-2.0.1 typed-ast-1.5.2 typing-extensions-4.1.1 wrapt-1.13.3 zipp-3.7.0
pi@email-pi:~ $ 

Extracting the photos from your email

Now send one or two emails with photos attached to the email that you will be using for your picture frame. In the email subject line enter “picframe” (without the quotes).

Check that you have a directory on your Pi that is called “Pictures”. If it’s not there yet, create it.

The attachment-download package has a number of options but if you want a simple solution, here is what you need to know: The generic command for extracting photos from your emails is:

/home/pi/.local/bin/attachment-downloader --host XXX --username XXX --password "XXX" --imap-folder Inbox --output /your-directory/ --delete --subject-regex=XXX >/home/pi/email.log 2>&1

I’ll walk you through.

What you need from your email provider is the IMAP Server. In my case this is imap.web.de.

Username” is your email, in my case thedigitalpictureframe@web.de.

Password” says it all. It is put in quotes.

Output directory” is where the photos are stored on your Raspberry Pi. I use /home/pi/Pictures/.

subject-regex” is the secret code word that tells your Raspberry Pi that this email is destined for your photo frame. In my example below it is “picframe“. I would use one word only, spaces might make it more complicated.

>/home/pi/email.log 2>&1” is for adding a small log file that is written in your home directory.

So here is my customized script (Thanks to reader Daniel) that I use based on the information above (note to hackers: my password is fake of course):

/home/pi/.local/bin/attachment-downloader --host imap.web.de --username thedigitalpictureframe@web.de --password "Cg@KreBVö843AQQk4^S&xU*EP2f85&NP" --imap-folder Inbox --output /home/pi/Pictures/ --delete --subject-regex=picframe >/home/pi/email.log 2>&1

This command does the following:

It checks your email account if there are emails with a subject line that matches your code word “picframe“. If there are any attachments, they will be downloaded and stored in your /Pictures folder. Following the download, the email will be deleted.

Several images can be included in one email, and all are downloaded. Note that there is a size limit to emails, often 20MB.

Just tell your friends & family to send the photos with the highest resolution setting and to not resize them in the email program. That way, you will have the best photo quality in your digital picture frame.

Automatically check your email every hour

To call this script every hour, you have to modify your crontab file.

In Terminal enter

crontab -e

and add the following line in the editor, of course replacing your user name, password, etc.:

0 * * * * /home/pi/.local/bin/attachment-downloader --host imap.web.de --username thedigitalpictureframe@web.de --password "Cg@KreBVö843AQQk4^S&xU*EP2f85&NP" --imap-folder Inbox --output /home/pi/Pictures/ --delete --subject-regex=picframe >/home/pi/email.log 2>&1

Conclusion

A big “Thank You” again to Daniel who pointed out the coming issues with Gmail and who also suggested an alternative solution! And, of course, James for his wonderful script!

Was this post helpful?

Scroll to Top