Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mail API with ability to group messages to a sender by delivery time [closed]

For our product we need to be able to schedule email messages for a recipient. Our product also wants to ensure that the recipient doesn't get spammed by too many messages. So, we are looking for an API that allows our product to schedule the messages over to the API and if the API finds more than one message scheduled for the same time, then it combines them in a reasonably intelligent manner.

Example, the product calls API with following requests:

  • to: [email protected], title: "You need to approve request 123" message: "XYZ", schedule: 2PM
  • to: [email protected], title: "You request for 234 has been approved" message: "PQR", schedule: 2PM

At 2PM, [email protected] receives the following:

  • title: "Messages from Product"
  • messages: <Combined message from title and message of the two above>

It seems that MailGun fits our general requirements except for this one requirement. Is there an API that solves this? If not, how do others solve it?

like image 258
Shreeni Avatar asked Jun 09 '14 02:06

Shreeni


1 Answers

You could create a simple database with two tables, "recipient" (name, e-mail adresss) and "message" (date_created, body, …). The relation of recipient to message is obviously 1:n.

Then you set up a cron job, collecting all messages that are older than, let's say, 5 hours; group them by recipient, wrap the messages into a nice template and pass them to the MTA.

Btw, I personally think that it's acceptable to send several e-mails within a short period of time – given that each e-mail is meaningful and self-contained. It is very nice of you to try reducing e-mail traffic, but in most cases, people won't mind, and they'll appreciate the instant notification.

like image 125
lxg Avatar answered Nov 04 '22 00:11

lxg