# How do I get cron mail?

## doro1211

Basically, I want to be able to use a simple shell command to send the results of a cron job to a mail account I can read so that I can verify that it's working etc.  I don't need outside connectivity, I already have email accounts for that.  Basically, I want all my computers to send email to one central place that I can access from an email client like thunderbird.  I want to keep this simple.

How do I do this?  What software do I need?

Thanks.

----------

## BrummBrumm

you will need to configure your mta (e.g. postfix or ssmtp )

have a look at http://gentoo-wiki.com/TIP_Postfix_Setup_for_Local_Mail_Only

cron should then deliver the output of the commands to the given user (MAILTO=user in /etc/crontab)

----------

## doro1211

Is it possible to use this to have multiple machines on the lan send mail to one central account so I don't have to check 10 accounts?

----------

## BrummBrumm

this is possible, but i do not know how to realize it :)

maybe you can just forward your messages to the other computers via /etc/mail/aliases (e.g. user@server-ip-adress) but then your server has to listen for incoming mail. there should be howtos out there :)

----------

## bunder

 *doro1211 wrote:*   

> Is it possible to use this to have multiple machines on the lan send mail to one central account so I don't have to check 10 accounts?

 

ssmtp on the machines, and postfix on the machine you want all the mail to end up at.  or you can tell ssmtp to redirect to an external email like gmail, but they'd probably get marked as spam on the way out.

cheers

----------

## doro1211

I think I'll try that.

I've been reading some wiki's... I'm have tempted to try creating a domain with DynDNS and having my own email server... of course, everything I send will get marked as spam... but what the hey... I still have gmail and some other accts.

----------

## Hypnos

I have my cron mail sent to a gmail account, from a gmail account.  Hopefully this isn't against TOS   :Smile: 

Here is my /etc/ssmtp/ssmtp.conf (place your info for the placeholders in all caps):

```
# The person who gets all mail for userids < 1000

root=MY-EMAIL@gmail.com

# The place where the mail goes. The actual machine name is required

# no MX records are consulted. Commonly mailhosts are named mail.domain.com

# The example will fit if you are in domain.com and your mailhub is so named.

# Example for SMTP port number 2525

# mailhub=mail.your.domain:2525

# Example for SMTP port number 25 (Standard/RFC)

# mailhub=mail.your.domain        

# Example for SSL encrypted connection

# mailhub=mail.your.domain:465

mailhub=smtp.gmail.com:587

AuthUser=MACHINE-EMAIL@gmail.com

AuthPass=MACHINE-EMAIL-PASSWORD

# Where will the mail seem to come from?

#rewriteDomain=BLAH

# The full hostname

hostname=FAKE-MACHINE-HOSTNAME

# Set this to never rewrite the "From:" line (unless not given) and to

# use that address in the "from line" of the envelope.

FromLineOverride=YES

# Use SSL/TLS to send secure messages to server.

#UseTLS=YES

# Use STARTTLS SMTP command to initiate SSL, you should enable UseTLS too

# for this option to work

UseSTARTTLS=YES

# Use SSL/TLS certificate to authenticate against smtp host.

#UseTLSCert=YES

# Use this RSA certificate.

#TLSCert=/etc/ssl/certs/ssmtp.pem
```

Running a local MTA is more robust, however -- you can get emails when the machine is offline, and nothing sensitive will get passed unencrypted over the Intertubes.  Follow this guide.

----------

## doro1211

Is it possible to:

1) deliver all to a single server, but have them show where they came from (e.g. email from root@moe, root@curly, root@larry, etc)

2) read them using thunderbird

I have enough accounts I check already, I'd rather not have to have more.  (Thunderbird groups them nicely so I just check one app for all my emails.)

----------

## Hypnos

Yes, I think that is the default with either postfix or ssmpt; you can get more sophisticated behavior with aliases.

----------

## doro1211

After I set up postfix, how am I supposed to check the mail?

I set it up just locally on one machine to start, but I cannot seem to make it work.  I can't figure out how to check mail, and I don't think it's working anyways...

Grrr... it's funny, local mail is the one thing in Linux that continues to elude me, and I have a feeling it's so simple...

----------

## Hypnos

You have to pick up the mail at the local mbox provided by postfix.

I forget where it is ... check the man page, and set up your mailreader to pick it up there.

----------

## nephron

i use dovecot to get it by imap pop3 impas and pop3s

edit: look at ISP-like Mail-Server

----------

## BrummBrumm

Hi. This is configured in /etc/postfix/main.cf

e.g. if it should be saved in mbox-Format

```

home_mailbox = Mail/SystemMail

```

or

```

home_mailbox = Mail/SystemMail/

```

if it is a directory. 

Your mails will be saved in ~/Mail/SystemMail (as a file)

or in ~/Mail/SystemMail/ (as a directory in which the mails are stored as files).

----------

## doro1211

Mine is set to /data/Mail/

There is nothing at all in the directory.

----------

