The popular IMAP server Dovecot supports compression incoming Mails in order to save disk space on the server.
This feature can be enabled by using the zlib plugin.
Installation and configuration is very simple, just add “zlib” to the mail_plugins configuration.
If you want you can specify the level of compression too – but the default value is just fine.
mail_plugins = $mail_plugins zlib
Only new Mails get compressed upon arrival. Existing Mails stay as they are.
As soon as a new Mail arrives, it gets compressed and is stored in your mailbox. If you have a closer look on the actual mail file you see that it is not a ordinary text file but a compressed file.
[root@server cur]# file 1398234.M33854922198.mail.server.com,S=2420,W=2465:2,S
1398234.M33854922198.mail.server.com,S=2420,W=2465:2,S: gzip compressed data, from Unix
Additional information can be found in the Dovecot Wiki.
(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