Search code examples
javaemailservletsjakarta-mail

Creating an email scheduler with Java


I'm creating a small program whose task is to send email to multiple users(broadcast) at a specific time.

I read some documentation and learnt that I have to use the JavaMail API in order to send emails.

Still, I have a lot of doubts.

The concept I have in mind is to create this small user interface where the user writes down the email content, selects the contacts from a stored private database and finally sends everything to a Servlet which should do the whole job.

Here are my issues:

  • Assuming this makes sense, I have to upload my Servlet online, which I never did before and I have no clue about how doing so
  • I read that something like this could be achieved with Windows Task Manager, which I never used but I suppose it doesn't work if the PC is turned off
  • If the idea of using a Servlet the way I described is correct, does this mean that the user application should simply send the email data to the servlet and nothing else? Is there anything I'm missing here?
  • I've seen some JavaMail examples and it seems pretty simple to use, even too much: don't I have to care about the whole IMAP, POP3 etc protocols ordeal?

Solution

  • This question is way too general and open ended, but here are some answers to get you started on the research you'll need to do.

    • You need a Java server such as Tomcat or a Java EE application server to run a servlet. There are lots and lots of ways to get, find, use, purchase, etc. such a server.
    • Search for "Java cron" or "Java job scheduler".
    • You can run the user interface as a standalone Java program, as an app on a phone, as a web application, or lots of other choices. Whatever you choose, you can send the data to the servlet and let it do the hard work.
    • JavaMail takes care of all the email protocol details for you. Using JavaMail to send the message is probably the easiest part of what you're trying to do.

    Good luck!