Sunday, May 5, 2024
 Popular · Latest · Hot · Upcoming
9
rated 0 times [  9] [ 0]  / answers: 1 / hits: 77053  / 2 Years ago, tue, october 18, 2022, 2:40:15

I want to send a fixed email reminder from my email address every Monday, Wednesday and Friday to a bunch of people.



How do I go about setting this up using crontab?



I have an email account on the mail server where I will setup the cron job, but the outgoing mails will be to gmail and hotmail accounts.


More From » email

 Answers
2

First, see this post to see how you can send an email from terminal. Once you solved this problem and you can send emails from terminal, the following method should work to setup cron job to send emails.



Edit the crontab entries using crontab -e command (by default this will edit the current logged-in users crontab) and add the following line:



0 0 * * 1,3,5 $HOME/scripts/send_email.sh >> $HOME/tmp/out 2>&1


Now you should create send_email.sh script. Something like this:



#!/bin/bash

recipients="[email protected] [email protected] [email protected]"
subject="...Subject..."

cat $HOME/email_message | mail -s $subject $recipients


$HOME/email_message is the message (file) you want to send.



Don't forget to grant execute access for the script:



chmod +x $HOME/scripts/send_email.sh

[#29947] Wednesday, October 19, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
poefor

Total Points: 379
Total Questions: 95
Total Answers: 115

Location: Serbia
Member since Tue, Jul 26, 2022
2 Years ago
;