- register/unregister (add and remove address to/from list in database)
- send a welcome mail on registering
- auto-send each day
I made some notes about how I would achieve each element ready for when I woke up before finally dropping off.
Adding and removing your address is fine and the welcome mails go out correctly while redirecting you to a separate welcome page. Removing your address provides a prompt rather than redirecting to a separate page.
Each address in the list is added as a BCC to preserve subscribers privacy. Using wp_mail they are each added as a separate header item so I have to loop through them individually. As an additional privacy measure I might look at encrypting the addresses in the database but that's for another day.
It's a bit rough and ready, and could probably be made a little (okay, a lot) prettier, but it seems to do the trick.
As with the custom RSS feeds, it's not something I anticipate anyone actually signing up for. I just thought it was worth a shot at creating as much for the intellectual exercise than the functionality.
Maybe, in future, I could hook into it to send additional mails or a newsletter and have it all self-hosted rather than relying on a third party service like Mail Chimp.
I was thinking more last night about how I would implement a self-hosted newsletter to tie in with the daily email list subscription list. To this end I've created a custom post type to hold it. It will work by using a combination of my custom posting form and the mail generation code. I create the newsletter as though it was a normal post, hit submit on the form and it then takes the content, transposes it for the mail and automatically sends it to the list. It's actually a lot simpler than I imagined and I've already done all the hard work. I just need to build the form (which will be on a separate page template) and repurpose the mail generation code. If this became a thing I would probably need to stop the daily post emails going to the same list, as this would be overkill, or provide opt in choices.