How to create a 'schedule email' feature?

My goal is to create a feature where our users can create email sequences and have them sent out at certain times. (think email marketing software like ActiveCampaign, MailChimp etc.)

How can I let the user schedule these in? Basically they would be creating cron jobs?
I need some thoughts on how to approach this.

So far I’m thinking:

  1. User can create an email in our CMS, consists out of:
  • Subject
  • Preview line
  • Body
  • Sending date+time (they can’t set the ‘seconds’ online hours + minutes)
  1. The user can fill this in, then it’s saved in the DB
  2. I run a cron job every minute that checks if there’s any emails to be sent out at this date+time
  3. Cron job sends emails to this user’s list

I’m not sure if this is smart, as this means there can easily be 100 000’s of emails to be sent in a minute. Let’s say a user has an average list size of 5000 people… this might be a huge burden on the server?

I do something similar. I’d recommend looking at using a third party platform to send the mails. I’ve used SindInBlue before but there’s a few around to evaluate.

A couple of things I’d recommend is storing the Mail body in a separate table to the recipient, date, sending complete flag, messageid etc, linked by foreign key. Also, think about batching messages with the same content and only storing one copy of the message body.

1 Like

Thanks for the input @bpj

We chose for Mailgun - but haven’t set up much yet.
I now see they do have some scheduling/bulk sending features, so I can use that I suppose.

Good point on splitting the email body in a separate table.

I realise my question I have an answer to my OP, but not to what I really want to know: I basically have this same logic but then for Whatsapp reminders.

Basically, I want to know: how can I let a user schedule a cron job? And/or are cron jobs the appropriate way to do this (I read they sit in the memory and can take up a lot of memory).

Simplified:
How can a user schedule a server action at a certain date+time they decide?

@bpj or have you already given me the answer: and you do that by:

  1. storing the datetime of when it needs to be sent + recipients + message (or email) body in the database
  2. Run a cron job every min(?) with a server action that checks those tables if there’s something to send out
  3. Run an api action that sends out these emails/whatsapp messages/ whatever it is

It seems quite a manual way of doing things that won’t scale.

I think you should consider https://www.postbacks.io/

1 Like