• 0

[JAVA] Send Email at specific time


Question

Hi guys,

I'm using a Linux platform running Java Servlets and a MYSQL db.

Just need a point in the right direction i think..I can write a servlet to send an email easily enough, but I want to send these emails out at a specific time. For example:

User wants to be alerted at 2:10pm that their order is ready (though the time now is only 10am) - I want to send this email at 2:10pm.

I've had a think here is my first idea:

  • When a email is to be sent at a specific time, its details are inserted into the database with the time to be sent
  • Schedule a task in Cron to run a Java Application every ten minutes.
  • This java application reads from the database the emails which need sending.
  • Sends the emails.

Is there a better way to this?

Cheers,

Greg

Link to comment
https://www.neowin.net/forum/topic/666428-java-send-email-at-specific-time/
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Your probably doing it the best way.

Web applications by nature aren't continously running processes. When they've done their work, they finish. Unlike client-side (or desktop for lack of a better term) applications run, they will keep running until they have been told to shutdown, so scheduling tasks are easy because they can be left alone. With web-applications, they generally only get initialised when a request is made to the server, or a scheduled task (by a continuously running process).

Leave it as is :)

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.