The Dot Forward File

When starting Terminal you may notice a ‘You have mail’ message. You may even know of the mail command and how to traverse your mail.

This can be unexpected if you’ve never configured a script or service to send mail to your user. However, some services, like crontab, are configured to send STDOUT to your mail account by default.

The convenience of mailing logs, error reports, or statuses can be sullied by learning and tracking another system. As always, there is an easier way.

A .forward file or ‘dot forward file’ in your home directory will  tell your system where that mail should go. Simply running the below will redirect that mail to your account.

echo "me@mail.com > ~/.forward"

You can include multiple addresses and separate them by comma “me@mail.com, you@mail.com”.

This allows you to receive the notifications in the mail application of your choice.

The dot forward file is a part of dot-courier. It can be configured to send mail to a program or append to a file. I found Dr. Nikolai Bezroukov’s article to be helpful in understanding what the dot forward file can do.

 

Leave a Reply

Your email address will not be published. Required fields are marked *