Custom mailing list system

116 Views Asked by At

On our website we use a MySQL table which contains all users. Some of the users should be able to send mails to all users. Unfortunately I haven't got the right idea how to implement such a system.

My current design:

  • A privileged user writes a mail to [email protected] using his personal mail software.
  • A server is waiting for incoming mails.
  • As soon as it receives a mail, it matches the 'From' field with the database.
    • If the user is not found or hasn't got the special flag, discard the mail.
  • Forward the mail to all users (mail addresses are saved in the database)
  • Send the sender a confirmation mail.

How can I implement such a system? I'm not required to stick to a certain programming language even though C++, PHP or Node.JS would be preferred.

1

There are 1 best solutions below

0
On

As a jumping off point, look into IMAP/SMTP. You can, with any language, log into an email inbox, get emails, read them, etc etc etc. Set up your mailbox with an account [email protected] that receives legitimate emails. Then set up a cron job that checks the inbox every 5 minutes or so. If no emails are found, then you are done. If there is an email there, process it, run your checks against your DB, and then send it using SMTP, and then send the confirmation to the user.

If handling IMAP is too hard, you may just want to make a form on your website that privileged users can use which sends the emails to the users.