(Automatically) send emails from the command line is very common and useful for a lot of reasons. There are a lot of different tools available to accomplish such a task.
Today I want to present how you could use mutt to send (yeah, it can do a lot more – it is in fact a feature-rich email client) emails from your shell cli. Mutt is around since the early days of the Internet and can handle almost every task you want to do in connection with emailing. Mutt can do a lot more but I will just focus on how to set up mutt so it can talk to your Google Mail account (and send emails via this account).
Use your favorite package manager to search and install mutt. If you want to compile it for yourself you can get the source code from the mutt website.
Next you have to configure mutt so it can talk to Google Mail.
Head over to your home directory (like cd /home/user) and create a file called .muttrc
Open .muttrc with your favorite text editor and paste in the following configuration (remember to fill in your details).
set from = ""
set realname = ""
set imap_user = ""
set imap_pass = ""
set folder = "imaps://imap.gmail.com:993"
set spoolfile = "+INBOX"
set postponed ="+[Gmail]/Drafts"
set header_cache =~/.mutt/cache/headers
set message_cachedir =~/.mutt/cache/bodies
set certificate_file =~/.mutt/certificates
set smtp_url = "smtp://@smtp.gmail.com:587/"
set smtp_pass = ""
set move = no
set imap_keepalive = 900
If mutt complains about not being able to connect make sure you have enable IMAP for your Google Mail account.
Now send an email to firstname.lastname@example.org echo "This is the body of your mail" | mutt -s "This is the Subject" email@example.com
and now send “image.png” as attachment: echo "This is the body of your mail" | mutt -s "This is the Subject" firstname.lastname@example.org -a image.png
and now use the content of the file “/tmp/testtext” as body: cat /tmp/testtext | mutt -s "This is the Subject" email@example.com
Every once in a while you want to check if a new firmware for your RaspberryPi is available. It brings new features (SD card support, new/different/better file system support, …) or irons out bugs and errors.
You can get the new files from the GitHub repository located here
Read through the changelogs to see what’s new
As I didn’t want to manually download the files and copy them to the right location I found the rpi-update tool (it is on GitHub too). It makes live really easier!
Just follow the given instructions and it will automatically update the firmware of your RaspberryPi.
The tool even automatically detects your ARM/GPU RAM layout and applies the correct start.elf file (to /boot).
“Moving” the available RAM
The RaspberryPi “only” has 256MB RAM (which isn’t that much nowadays) in total. As described here you can shift the available RAM to either the GPU or the system. Depending on the way you are going to use your RaspberryPi.
If you don’t use the HDMI port at all (and no X11) you can use the “224M ARM, 32M GPU split”.
This is done by renaming the arm224_start.elf to start.elf on your /boot partition. The next time you reboot your system you have 224MB RAM available.
In my last post here I talked about the Raspberry Pi I received earlier that day.
Due to some “design limitations” of my monitor I wasn’t able to use the HDMI port of the raspi (short for Raspberry Pi) nor did an adapter (HDMI -> DVI) help to solve the problem. So I skipped the “graphical part” and continued “shell-only”.
Problem 1 – SD Card
After flashing the latest available Arch Linux image on my shiny new Kingston 32GB SDHC card (and re-sizing the partition with gparted) I was able to boot Arch Linux and access the box via SSH. First I was happy but then I looked into the logs (dmesg and /var/log/everything.log) and saw a lot of read/write errors and re-initialization attempts of the SD card. After some searching I found out that a “VerifiedPeripherals” list exists.
So before buying a – expensive – SD card, or any other hardware, have a look on this list first: RPi_VerifiedPeripherals.
My Kingston 32GB Class 10 SD Card didn’t work for instance but the Sundisc 20GB Class 6 works perfectly – It is the card with the number/identifier “BI1131422083D” on the back.
Problem 2 – Getting around in Arch Linux
I decided to use Arch Linux on the raspi as I wanted to have/try something different. Arch Linux has a very extensive repository with pre-built packages for ARM devices (the same is true for Debian too btw.) and comes as image for the Raspberry Pi.
You can get the latest image from the Raspberry Pi download-page. Just download the zip file, unpack it and use dd to flash it onto the SD card.
For details on this please visit this wiki page
After flashing the image on the card you can use gparted to re-size the 1.9G partition so that it fills the whole disk.
You can now mount the partition and make direct changes to the system before even starting up the raspi (like enable/configure ssh, set time zone, …)
If you have never worked with Arch Linux you have to get used to different commands like “pacman” (package manager). There is a short and simple listing of the most important commands you might need at the Arch Linux ARM Guide section.
First command for me was “pacman -Syu” (works like apt-get update; apt-get upgrade on Debian) to update the system. After a few minutes a got the error:
error: failed to commit transaction (conflicting files)
hwids: /usr/share/hwdata/pci.ids exists in filesystem
hwids: /usr/share/hwdata/usb.ids exists in filesystem
systemd-tools: /usr/share/man/man5/hostname.5.gz exists in filesystem
systemd-tools: /usr/share/man/man5/locale.conf.5.gz exists in filesystem
systemd-tools: /usr/share/man/man5/vconsole.conf.5.gz exists in filesystem
Errors occurred, no packages were upgraded.
After some searching I found out that you can safely ignore this error. Just rename the files in question and run “pacman -Syu” again.
[root@alarmpi ~]# mv /usr/share/man/man5/hostname.5.gz /usr/share/man/man5/hostname.5.gz.save
[root@alarmpi ~]# mv /usr/share/man/man5/locale.conf.5.gz /usr/share/man/man5/locale.conf.5.gz.save
[root@alarmpi ~]# mv /usr/share/man/man5/vconsole.conf.5.gz /usr/share/man/man5/vconsole.conf.5.gz.save
[root@alarmpi ~]# mv /usr/share/hwdata/pci.ids /usr/share/hwdata/pci.ids.save
[root@alarmpi ~]# mv /usr/share/hwdata/usb.ids /usr/share/hwdata/usb.ids.save
I had to reboot once to apply all updates and after running “pacman -Syu” again my system was up-to-date.
Well, after I managed to overcome the first problems I am very pleased with Arch Linux on my Raspberry Pi
Thanks for reading!
If you haven’t been living behind the moon for the last couple of months you probably heard about the Raspberry Pi. I am not going into detail about what it is, why it was developed and what it can do – just head over to the FAQ’s at the Raspberry Pi website at http://www.raspberrypi.org/faqs and have a look for yourself.
Well, after waiting some weeks it finally arrived yesterday. As I do have some ideas what to do with it I am pretty excited that it finally arrived
(Sorry for the blurry image)
It is designed to boot from a SD card and you can download different Linux images (Arch Linux, Debian and QtonPi) from the Raspberry Pi website.
My first test was to flash the current Arch Linux image on a SD card, apply power and watch it booting up at the connected TV screen.
So far so good