23

I have added a cron job for my incremental backup, and I configured it like this:

0 23 * * * /usr/bin/rsync -ravzX /mnt/external/project/ /media/backup/project/ | mail -s "Backup Success" admin@example.com

But i didn't receive any e-mails.
How can I find out what's wrong?

aseq
  • 4,740
Booth
  • 548

3 Answers3

42

You can use the MAILTO option in crontab to define your email address and receive all output and errors in all crons running.

open crontab using

crontab -e

on the top of the file use MAILTO option as

MAILTO=email@example.com

cron looks for MAILTO feature to decide where it should send cron logs. it send is to root by default if the crons are running with root.

put it there on the top and remove any mail command reference from the crons.

Test and verify if you receive cron alerts after this.

aseq
  • 4,740
sandeep.s85
  • 2,189
3

On FreeBSD

1: Check log:

tail -f /var/log/cron
tail -f /var/log/maillog

2: Replace sendmail with ssmtp vi /etc/rc.conf file.. and add:

sendmail_enable="NO"
sendmail_submit_enable="NO"
sendmail_outbound_enable="NO"
sendmail_msp_queue_enable="NO"

3: Launch following commands:

killall sendmail
cd /usr/ports/mail/ssmtp/
make install replace clean

4: Edit ssmtp conf file:

vi /usr/local/etc/ssmtp/ssmtp.conf

.... and add following lines:

root=yourrealemail@example.com
mailhub=smtp.example.com:465
RewriteDomain=example.org
UseTLS=YES
AuthUser=user@example.com
AuthPass=password222
FromLineOverride=YES
Hostname=yourhostname

5: Enter following command:

echo ‘ssmtp_enable=“YES”’ >> /etc/rc.conf

p.s. other explained options of ssmtp.conf are here:

http://www.techrepublic.com/blog/it-security/use-ssmtp-to-send-e-mail-simply-and-securely/

aseq
  • 4,740
3

Problem in this case was that message had been delivered to spam folder on gmail (which is always worth checking). Adding sender as a contact should avoid this.

Apart from that, looking at the received message's full headers may give clues as to why it was flagged as spam (and so how to influence filtering not to do this).

Paul Haldane
  • 4,612