Recently, while reconciling my company accounts, I found I was missing an email receipt. I was able to retrieve a copy of the email as a .eml file, but to store it with my other emails I needed some way to import it into my email system.
I currently store my emails on a server running Ubuntu. Locally I use a Maildir format folder and serve it to my other client machines using IMAP with the Dovecot program. On the server I use the getmail program to collect my email from several different Internet mail servers and send them to my Maildir folder. The server does this automatically for me at regular intervals as I set them up as cron tasks.
How can I get a .eml file into my system?
One approach uses the Thunderbird email client program. This program recognises the .eml file so, to import it to any email folder, you can just drag and drop the file. Since I use Thunderbird on my Windows machine as a client to my IMAP folders this allows me to store the email on my server too.
But, on my Ubuntu machines, I tend to use the Evolution email client, as that’s currently the default program for email. Unfortunately, Evolution doesn’t understand the .eml file format in the way that Thunderbird does. However, the getmail package also comes with the program getmail_maildir. Here’s how to use it to import an email into a local Maildir format folder from a terminal or shell:
getmail_maildir ~/Maildir/ < email_file.eml
- getmail_maildir is the name of the program.
- ~/Maildir/ is the location of the Maildir format folders:
- the ~ is a shortcut that means the current user’s home directory.
- the trailing / is required.
- The < tells it to pipe the contents of the following file into the program.
- email_file.eml is the file you want to import