I am new in Pi Camera and RaspberryPi. I want to send the captured image to email. How can I do it?
The easiest way to do this is by breaking it into steps:
We want to capture an image. Do this using
raspistill -o ./example.jpgwill take an image and save it as
example.jpgin your current directory.
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 firstname.lastname@example.org < /dev/null
This will send an email to
email@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).
(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 firstname.lastname@example.org < /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.
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.