1

I am new in Pi Camera and RaspberryPi. I want to send the captured image to email. How can I do it?

3

The easiest way to do this is by breaking it into steps:

  1. We want to capture an image. Do this using raspistill: raspistill -o ./example.jpg will take an image and save it as example.jpg in your current directory.

  2. Send an email, with the image as an attachment. The most friendly email client in this situation would be mutt. The syntax you need is as follows:

    mutt -s "Subject" -a ./example.jpg example@example.com < /dev/null
    

    This will send an email to example@example.com, with the attached image, and a subject of "Subject". The body will be empty (the file to the right of the < is the body of the message; replace it if you need to).

  3. (Optionally) Put this all in a shell script so you only have to run one command rather than remembering two more complex commands.

If you did want to put this all together in a script (say, email_image.sh), you would need to add:

raspistill -o ./example.jpg
mutt -s "Subject" -a ./example.jpg example@example.com < /dev/null

If you create a file with that as the contents, then run chmod +x ./email_image.sh, you will be able to execute the whole thing by typing ./email_image.sh on a new line and pressing enter.

You will likely need to configure Mutt with your email settings. The Debian wiki outlines the necessary steps to do this, and if you have issues, you should be able to find additonal guides elsewhere. The Arch Linux wiki is often useful as a resource—even if you're not using Arch itself, the configuration of Mutt is still the same, and is described in detail there.

| improve this answer | |
0

To capture the image, the previous answer is good, if you're using Raspbian.

For the second part, if you don't want to install an extra client server, you can use Python to send your image in a email. There is plenty of documentation on the web. Look at this link or this tutorial for instance. Python is a good choice on RPi, as there are a lot of projects.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.