7

My cron jobs sometimes sends mail to /var/mail/USERNAME. I normally read it by log on the Mac computer and run mail command to read and delete these mails. But how to deliver/forward such mails to my Gmail automatically? I would like to read such mails from different Mac computers in one Gmail account.

2 Answers 2

2

On my High Sierra (10.13.4) machine, mail honors the .forward file. Create a file in your home directory called ".forward" containing an email address. All your mail on the Mac system will be forwarded to this address.

It makes good sense to limit access to this file, with chmod.

For example (open Terminal in your home directory):

cube:~ borg$ cat > .forward
[email protected] <return>
<ctrl-d>
cube:~ borg$ chmod 600 .forward

Then you can test by sending a mail to yourself, from the command line:

cube:~ borg$ mail borg
Subject: test
This is a test.
<ctrl-d>EOT
cube:~ borg$ mail
No mail for borg
cube:~ borg$ 

Note: this only works for forwarding MacOS system mail, not for forwarding from any of your cloud mail services. You can enter any valid e-mail address in the file.

1

To manage mail routing on *nix system you should configure your MTA. Here is extensive manual about MTA capabilities in OSX systems

1
  • This might not be the simplest, most useful answer.
    – Matt
    Commented Apr 12, 2018 at 19:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .