I had a problem that gmail was blocking emails sent using mailx. I solved this by setting up an appropriate ~/.mailrc, which looks like:
set smtp-use-starttls set nss-config-dir=/home/theuser/.certs set ssl-verify=ignore set smtp=smtp://smtp.gmail.com:587 set smtp-auth=login set smtp-auth-user=xxx set smtp-auth-password=yyy set from="[email protected](Rabbit Server)" So now when I run:
echo "hi" | mailx [email protected] my emails send successfully as user and as root.
Now I want cron to work as well. I changed "/etc/sysconfig/crond" to force it to use mailx, with:
CRONDARGS="-m /usr/bin/mailx" I have ~/.mailrc setup at:
- /root/.mailrc
- /home/theuser/.mailrc
- /etc/.mailrc
But no matter what I do, echo output is not emailed successfully.
The crontab looks like (and I've checked, the scripts are running and doing their job, and echoing, just cron isn't sending emails):
MAILTO="[email protected]" # Every minute check processes are running, restart if necessary and send an email. * * * * * source /home/theuser/.bashrc; global audit_regular # Every day, send an email describing the state of the host and its jobs. 0 5 * * * source /home/theuser/.bashrc; global audit_daily # Every Monday at 7am, archive the logs. 0 7 * * 1 source /home/theuser/.bashrc; global archive_logs Also, this crontab is setup on another host and sending emails fine.