Should I build a PHPMailer video training course?

I spend a lot of time working on PHPMailer, and even more answering questions about it on Stack Overflow, yet gain very little from doing so. There is a certain amount of professional pride and reputation involved, but that doesn’t pay the bills. I am lucky enough to have a few GitHub and Patreon sponsors (thank you!), but that doesn’t amount to much. The same questions come up again and again, and repeating the same answers over and over, to people who are convinced that they must be the very first person ever to have had trouble sending email through GoDaddy, gets dull and tiring. I also run Smartmessages.net (a privacy-first email marketing service), so I am continuously exposed to large-scale email issues that small senders never have to worry about, but that are near-impossible to find advice about.

Email is a funny thing; it’s been around forever and is absolutely taken for granted, but it’s horribly complicated (way more so than, say, HTTP), and many developers, especially new ones, have absolutely no idea how it works – hence the repeated mistakes. Email grows more complex by the year, with the addition of things like SPF, DKIM, DMARC, ARC, MTA-STS and more. Some of it is really quite tricky yet the resources available for it either suck or are decades old. I’ve previously pitched book proposals to popular publishers (including O’Reilly and Packt) on “Modern email”, but have always been rejected on the basis that it’s not of interest or “outdated”, even though email usage is forever growing and changing.

So I’ve been thinking about putting together a training video course on using PHPMailer, diagnosing related problems, and using email in general. Such courses are apparently very popular, though I have to admit to not using them much myself, preferring text. I’ve been heartened by the success of projects such as Christoph Rumpel’s Laravel Core Adventures, along with his valuable advice on how he built that. I’ve been impressed by the lovely Jeff Geerling‘s dedication to his ansible book and audience, and have contemplated going the self-publishing route, but a book is a really big commitment, especially on such an enormous subject as email. Video courses are a bit more flexible, though keeping them up to date has its own issues, as Jeffrey Way has said about his amazing output on Laracasts.

The big issue is my audience. I know that it’s going to be primarily junior and novice developers with little experience needing help putting together their first contact form, so it needs to be pitched quite low, at least to start with. I gather that the primary feeder for video courses is social media, but my social media profile (principally Twitter; being a privacy advocate means I really don’t want to go anywhere near Facebook) is mainly more experienced developers, who are probably not the ones who need this kind of help, though you never know – it may just be my impostor syndrome assuming that all these clever people already know about this stuff!

In summary: there is fertile ground for such content, there’s little competition, I’ve got all the experience, equipment, and position needed to do it, but I need some help and encouragement with putting together a platform and reaching my audience. Finally, since I really need to dogfood this sort of thing, please sign up to my PHPMailer mailing list!

Domain name validation

I was revisiting the validation of domain names and realised that most of the regexes posted around the web have faults.

Many refer to Sean Inman’s 2006 post, which does a fair job but is prone to break as new TLDs are introduced. This answer on StackOverflow is about the best I’ve found so far: it enforces label and overall lengths; allowing multiple dashes means it works with punycoded domains; it’s generally permissive so won’t break as TLDs change, but there’s one case not handled. RFC2872 says that labels that are not used as hostnames (i.e. which do not map to an IP, for example in TXT or SRV records) may contain any printable ASCII character, so  `_,;:'”!@£~$` and friends are all up for inclusion. This is most commonly found in domainkeys, which use the `_domainkey` label. There’s a good article on the use of underscores in DNS.

This does relate to the validation of email addresses (which often contain domains), and the best page on that subject is this one, however, you can’t simply extract the domain part from that as domain names in general are a superset of what’s used in email.

It’s difficult to do this right because you can’t tell whether a label is a hostname or not, or where a hostname stops and a domain begins, and validity varies according to context: `_domainkey.example.com` is invalid in an A record, but valid in a TXT record. I can foresee a parameter to allow you to specify usage context to deal with this. It might be better to process the name backwards so that you have more context available as you encounter each label, for example if you processed `www.example.com` as `com.example.www`, you would stand a better chance of knowing whether www is a hostname or a domain name.

I’m mainly thinking out loud here, I don’t have a solution as yet!