I needed a way to perform a daily check that a Linux email server is able to successfully transmit email to external email addresses. Such a test can easily be scheduled using cron and mailx. You can use the crontab utility to schedule mailx to run periodically and send a test message to a specified email address. E.g., the following entry will send a test message at five minutes after noon every day to email@example.com:
05 12 * * * mailx -s "Daily email delivery test" firstname.lastname@example.org </home/jan/Documents/daily_mail_test_message.txt
The body of the message will contain the contents of the file
The first 5 elements on the line in the crontab file are scheduling elements:
# ┌───────────── min (0 - 59) # │ ┌────────────── hour (0 - 23) # │ │ ┌─────────────── day of month (1 - 31) # │ │ │ ┌──────────────── month (1 - 12) # │ │ │ │ ┌───────────────── day of week (0 - 6) (0 to 6 are Sunday to # │ │ │ │ │ Saturday, or use names; 7 is also Sunday) # │ │ │ │ │ # │ │ │ │ │ # * * * * * command to execute
If an asterisk is used for an element, that indicates that scheduling is done for every possible value for that element. E.g., the 05 on the line indicates five minutes after the hour, in this case 12 (noon) and the following three asterisks indicate that the cron job should be run every day of every month and every day of the week, i.e., Sunday to Saturday.
[ More Info ]