skip to Main Content

I am interested in building a website using react, and I want to allow users to choose whether to receive daily or weekly email notifications.
I don’t know how to set up server side, only client side.
Is it possible to schedule the sending of emails from the client side?
My problem is that apparently for this to happen the site would have to be open all the time.
My question is not about sending emails, but about the timing of sending emails.

I tried to find out about emailjs but I didn’t see there an option of email scheduling.
I know there is Google Cloud Scheduler, can it help me?
There is a preference for free solutions, but I would also like to hear about paid ones so that I can consider all the options.

2

Answers


  1. Scheduling the sending of emails from the client side can be challenging because, as you mentioned, the site would need to be open all the time for this to work. A more reliable approach for scheduling and sending emails would be to use server-side solutions. Here are some options for achieving this:

    Serverless Functions: You can use serverless platforms like AWS Lambda, Google Cloud Functions, or Azure Functions to run code on the server side at specific times or intervals. You can set up a function to send emails based on user preferences (daily or weekly).

    Cron Jobs: On a server, you can use cron jobs to schedule tasks, including sending emails. You’d write a script that runs periodically and checks for users who need to receive emails. Cron jobs are available on most hosting platforms.

    Third-party Email Services: Many email service providers, like SendGrid, Mailgun, and Amazon SES, offer scheduling and automation features. You can integrate these services into your backend to schedule and send emails based on user preferences.

    Regarding Google Cloud Scheduler, it’s a good option for scheduling tasks in a serverless manner. You can use it to trigger functions or HTTP endpoints at specified times or intervals. It can help you schedule email notifications and is relatively easy to set up if you’re already using Google Cloud services.

    For free solutions, you might consider serverless platforms like AWS Lambda (with the AWS Free Tier) or Google Cloud Functions (with their free tier). These services often provide a certain amount of free usage per month.

    Paid solutions like SendGrid and Mailgun offer more advanced features and reliability but come with a cost based on usage. They often have free tiers with limited usage, which can be suitable for small projects.

    Login or Signup to reply.
  2. You do not need a full fledged server if you only seek to achieve automated, recurring behavior for a task.

    But you have different options that depend on what you are already doing and what you plan to do:

    • If you’re using a linux based distribution: Have a script that sends email, this script would be standalone (meaning you could launch it manually if you want and it should work on it’s own, fetch your users from a DB, send the mails, then die). You can then use cron to schedule a reccurring task that will call your script. This is a great solution because cron doesn’t care which langage you use, it runs a shell command that should launch the right script.

    • If you already have a server (serving your front, for example) then look at cron-like libraries for your technology. Usually, i’ld assume nodejs, well: nodejs has a ton of packages you can install via npm that let you setup reccuring task. But that, however, will stop to work if your server dies. This is a more limited approach since not all langages provide such libraries, and is usually aimed more at scripts that use server logic to run their whatever it is they do.

    Note that you will need an "always" running server, in one form or another, it can be hosted by a third party, it can be your own machine, it doesn’t matter you need something that’s running at all time else how’s your script supposed to run ?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search