Apple’s Mail Plug-In system is quite amazing, and has led to some innovative and brave developments as an MUA (Mail User Agent). These brave developments include: wrapping long lines like a decent MUA, quoting messages in replies correctly like a decent MUA, and an option to Wrap Text like a decent MUA.
I actually forgot to install MailWrap on my M1 when I built it up, and haven’t noticed mostly because I haven’t been posting to mailing lists lately. However, I feel deep personal shame for posting on lkml without remembering to install it first. Look at those long lines!
So I set out to install MailWrap. It certainly is a lot more difficult than it used to be.
#1: Allowing the installer to access ~/Library/Mail
The first time I tried to install MailWrap, I received the unhelpful message that access to ~/Library/Mail/Bundles was denied. This is because I had to grant Terminal the Full Disk Access permission.
You can do this in System Preferences under Security & Privacy. You’ll be helpfully reminded that you have to restart Terminal. Hope you don’t have six active SSH connections open, like I did!
#2: Using the correct UUID
Now we need to add the correct UUID to the Info.plist file. Open ~/Library/Mail/Bundles/MailWrap.mailbundle/Contents/Info.plist in your favourite plain-text editor. Scroll to where you’ll find “Supported10.16PluginCompatibilityUUIDs” and then add the following lines under the “</array>” line:
<key>Supported12.2PluginCompatibilityUUIDs</key>
<array>
<string>6FF8B077-81FA-45A4-BD57-17CDE79F13A5</string>
<string>25288CEF-7D9B-49A8-BE6B-E41DA6277CF3</string>
</array>
Note that this says “12.2”; when 12.3 comes out, we will need to change this again.
#3: Sign and allow the bundle to run
Gatekeeper will try to keep you safe from untrusted code, which is generally a good thing. We can sign our bundle now:
$ cd ~/Library/Mail/Bundles
$ codesign -f -s - MailWrap.mailbundle
And now that it is signed properly, we can tell Gatekeeper to trust the signature:
$ sudo spctl --add --label “MailExtensions” MailWrap.mailbundle
$ sudo spctl --enable --label “MailExtensions”
Troubleshooting

If you receive this Incompatible Plug-ins Disabled message, then something has gone wrong with your UUIDs. You’ll need to try again and make sure that you’ve pasted those lines in the correct spot.

I received this message when I edited the Info.plist file after running codesign. It means the CodeSignature doesn’t match the contents. You need to re-run the codesign command every time you change any file in the bundle to keep the signature updated.

This message is because MailWrap uses Python 2.7. Hopefully I will have some time to update it to Python 3 before the eventual removal of Python 2.7 from macOS. I’ve had success doing this before, so hopefully it goes well.
In conclusion
Now my emails are nice and wrapped and I’m not breaking a bunch of email clients in faraway lands. And all was quiet in the world. (Except not: the kernel is still broken, and Ukraine is still being invaded.)
I hope this post was useful to you. Happy hacking!
Thank you so much for this! I actually went on to doing half my mail in the terminal in aerc but never fully got used to it …
Mailwrap now works great for me (after I found out that it does not show up in Extensions but that I have to enable it in “Manage Plug-Ins” in the General Preferences tab — just leaving this here in case anybody else struggles to enable it).
One question for when the next version comes: How do you find out the compatibility UUIDs?
Cheers,
-emw
LikeLike
Hi, I wrote MailWrap and MailFlow a few years back, and it’s great to read that it’s still useful to someone else!
I do still have access to a mac, but nothing beyond ‘Mojave’ (10.14.6), so I’ve not tested or updated these plugins beyond this point. But if you do have them working and don’t mind checking my work (as I’d be making fixes a bit ‘blind’), I’d love to try to update the instructions and fix any incompatibilities to make them easier for people who want to use newer macOS and Mail.app.
Do more recent releases of macOS have a system python 3 alongside the system python 2 now? Mojave doesn’t have anything but python 2.7. It was jarring out-of-date when I originally wrote them, but that’s Apple for you!
I really wanted to avoid talking people through installing third-party python plus the objective C bridge and appkit modules if at all possible – but if Apple are dropping system python entirely, that may be unavoidable. I don’t know whether any of the module interfaces I’m using have changed significantly between python2 and python3, but it’s conceivable I can fix the scripts to work equally well on either.
LikeLike
Hi, I wrote MailWrap and MailFlow a few years back, and it’s great to read that it’s still useful to someone else!
I do still have access to a mac, but nothing beyond ‘Mojave’ (10.14.6), so I’ve not tested or updated these plugins beyond this point. But if you do have them working and don’t mind checking my work (as I’d be making fixes a bit ‘blind’), I’d love to try to update the instructions and fix any incompatibilities to make them easier for people who want to use newer macOS and Mail.app.
Do more recent releases of macOS have a system python 3 alongside the system python 2 now? Mojave doesn’t have anything but python 2.7. It was jarring out-of-date when I originally wrote them, but that’s Apple for you!
I really wanted to avoid talking people through installing third-party python plus the objective C bridge and appkit modules if at all possible – but if Apple are dropping system python entirely, that may be unavoidable. I don’t know whether any of the module interfaces I’m using have changed significantly between python2 and python3, but it’s conceivable I can fix the scripts to work equally well on either.
LikeLike
Fyi, Apple just dropped python 2 entirely in macOS 12.3:
https://developer.apple.com/documentation/macos-release-notes/macos-12_3-release-notes
“Python Deprecations
Python 2.7 was removed from macOS in this update. Developers should use Python 3 or an alternative language instead. (39795874)”
LikeLike
PS The supported UUIDs are supposed to be generated automatically, but platform.mac_ver() is returning 10.16 instead of 12.2, I think because of Apple’s horrible SYSTEM_VERSION_COMPAT hack.
Does setting this to 0 in the environment when running the install.py script help?
If so, does it work to override it to zero in the script itself with something like
“`
os.environ[‘SYSTEM_VERSION_COMPAT’] = ‘0’
“`
?
LikeLike
I’ve just pushed an update allowing MailWrap to run with modern Python 3.x as well as system Python 2.7. I’ve included a variant of your recipe for code-signing with credit, as I’m unable to test myself. Many thanks!
Would be interested in feedback on how things run with Python 3.9+ on 12.2/12.3 with these fixes – it works fine on 10.14.6 with Python 3.9 for what it’s worth.
LikeLike