Send email every hour

SYSTEM INFORMATION
OS type and version Rhel9
Webmin version 2.101
Virtualmin version 7.7
Related packages SUGGESTED

I have a list of emails id’s. I want to send emails one by one every hour. Is it possible?

@Joe @Ilia Please guide me. thanks.

I don’t understand what you’re trying to do. There’s a lot of ambiguity in your description.

When you say “email id’s” you mean email addresses, I guess?

And, when you say “one by one every hour”, do you mean you mean you want the same single email sent to each email address an hour apart? Or do you mean you have a series of emails to send to each email address, every hour?

In either case, though, I don’t think we have any tools for exactly that. You can schedule an email in Usermin, but I don’t think you can to what you’re suggesting.

I think you’d probably need to make a custom cronjob to do it. Sending mail from scripts is dead simple; the only somewhat tricky part is implementing a queue to keep up with which email addresses have been sent which emails (if it’s more than one email).

Lots of examples of sending mail from the command line here: How to send an email using sendmail command in linux - Stack Overflow

@Joe Thanks for replying to me

I mean, I want the same single email sent to each email address an hour apart. Is it possible?

Anything is possible.

But, Usermin does not provide a UI for that use case. I’ve never heard of anyone needing to do that, so it’s not a thing any of us have ever considered as a desirable feature. You’ll probably need to make your own cron job for it. There’s a bunch of ways to do it, simplest is just to keep a count of which email address from the list you’ve already emailed…i.e. read a number from a file, increment it, send to the email address that corresponds to that line in the file, write the number out. Repeat an hour later.

I can’t write the script for you, but Linux has all the tools to do it in under a dozen lines of code. The problems to solve:

Reading a specific line from a file (based on line number): https://www.baeldung.com/linux/read-specific-line-from-file

Adding numbers (to increment line numbers): shell - How to do integer & float calculations, in bash or other languages/frameworks? - Unix & Linux Stack Exchange

I’d just use the POSIX shell option, e.g.:

linenumber=3
linenumber=$(($linenumber + 1))
echo $linenumber

You can read from a file with read variable_name < file_name and write to a file with echo $variable_name > file_name.

I think you can do it in about half a dozen lines of code, actually. Perl or Python or Ruby might be more readable, if you’re more familiar with them, but a POSIX or bash shell script can do it real quick.

1 Like

You could also use a php cli script. Php has the ability to send mail directly from a script has reasonable file manipulation in order to save the progress through the email list. If you need I’ll trot a small script out for you

Thank you Joe.

This is an India problem and I am glad you pointed it out. Many years ago, somebody in government decided that info@domsin.tld should be the default email address for the domain (the ignoramus had never heard of an autoresponder) and as a result of that almost everybody in India now uses an email address in that format.

More recently, someone in India’s nationalised banking system though it was clever to use email ID, since India already has half a dozen citizen IDs so why not one more, and everyone now refers to an email address as email ID.

If I ever get hold of that banker, I shall have a thing or two to say to him.