Documentation for Subscribe

Proof of concept to subscribe to a newsletter.

External Code
This project runs a vanilla version of Bootstrap by way of CDN.
MyPHPMailer is used to send the e-mails.
Basic Structure

This project has three main forms:

  1. Subscribe Form: The click event of the submit button is overridden in Subscribe.js which gets the form data and executes a fetch to Subscribe.php. The php returns an error if the e-mail is invalid. Else it tries to read subscribers.txt by way of AccessSubscribers.php, which may throw a variety of exceptions. subscribers.txt is an associative array with the e-mails as indices. If already subscribed it throws an exception, else it adds the e-mail and associated name (which can be empty) and gives a confirmation.
  2. UnSubscribe Form: The click event of the submit button is overridden in UnSubscribe.js which gets the form data and executes a fetch to UnSubscribe.php. Exceptions and confirmations are generated.
  3. Send Mail Form: The click event of the submit button is overridden in SendTheMail.js which gets the form data and executes a fetch to SendTheMail.php. The sending of any individual e-mail is done by way of MyPHPMailer.php and can take several seconds. A fetch is used to start the processing of the e-mails. Each e-mail will return a response. Another fetch needs to be done until the response contains ERROR or ALLDONE.
Notes