Embedding a post in a newsletter email blast can have you easily step on a particular landmine. I just did this yesterday and I’m posting this to help folks troubleshoot what must be a relatively common oops, but one where I couldn’t find it discussed previously … (Please correct me if I am wrong.)
I use Mailgun and I have it pump the entire post to my subscribers. I suspect most of you do as well. I have only recently moved to Mailgun after finally upgrading Ghost. I was using Mailchimp previously, where only the title, image, and excerpt of the post were being sent.
Many of my posts use more modern HTML and CSS.
In order to send the entire post to the mailing list, Ghost embeds the HTML and any inline CSS (I am unsure if a post’s code injection code gets embedded with it.) Ghost uses a library to do this: Juice. Now, this library has to ensure some degree of successful rendering of the email on all major email clients. This can be challenging because what email clients support is rather variable, and many are well behind on modern HTML and CSS standards. Read more here: https://www.caniemail.com/ (Hint: MS Outlook is awful.) Juice rightly supports the slower runners at the expense of the more modern ones, but … What it doesn’t do is fail very gracefully …
So, what happens if you use overly modern HTML and CSS in your post and then try to publish it to your mailing list? Juice will choke on it. Unfortunately, the error is utterly non-obvious: TypeError: Cannot read properties of undefined (reading 'match') A totally unhelpful error message.
And so, yesterday, I spent about 2 hours racking my brain why my post was not being sent to my subscribers. It created a test post and verified that Ghost could send it to a test email just fine. But it refused to send my latest post to the mailing list. All I had in my logs was that cryptic error. I figured it had to be something nuanced about my DNS settings or something about that post specifically.
To the rescue: AI.
If there is one thing AI is good at, it is reading cryptic log files and giving you suggestions that often lead down the right path.
I fed the AI (Google Gemini in this case) the relevant portions of the log file, what sending email address I was using for the mailing list, my Mailgun settings from Ghost’s perspective, my DNS table. and then I fed it the HTML of my post. Google Gemini instantly figured out the problem:
The landmine: There was a bit of inline CSS in my post that contained elements that were nested and used the & nesting selector. Tsk Tsk! says Ghost (via Juice library). Of course, I can use all of those neat configurations with the website itself, and with posts, but not for posts that are wrapped up in a container and sent to the mailing list, because Juice just won’t allow it.
So, how should do we deal with this? As I see it …
- Be aware. The error message I shared above means “Nope! Can’t send this post that uses your fancy/modern formatting to your email list!”
- Simplify your posts and, in particular, any inline CSS
- AI can be your friend when troubleshooting.
- If you want to get fancy with your post, simplify the first version that gets sent to your subscribers, wait until that succeeds, then reedit the post and add your more robust formatting if you like.
Thank the gods that AI deciphered this for me, or I would have utterly lost my mind trying to figure it out, I think. ;)
Good luck out there. Hope this helps someone. -t