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.
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.