{"id":32928,"date":"2021-06-23T16:14:39","date_gmt":"2021-06-23T20:14:39","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=32928"},"modified":"2021-07-07T11:58:25","modified_gmt":"2021-07-07T15:58:25","slug":"mail-app-extensions","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2021\/06\/23\/mail-app-extensions\/","title":{"rendered":"Mail App Extensions"},"content":{"rendered":"<p><a href=\"https:\/\/developer.apple.com\/videos\/play\/wwdc2021\/10168\/\">Apple<\/a>:<\/p>\n<blockquote cite=\"https:\/\/developer.apple.com\/videos\/play\/wwdc2021\/10168\/\"><p>Meet MailKit: the best way to build amazing experiences on top of Mail. MailKit enables apps to easily and securely interact with the Mail app for macOS. We&rsquo;ll deep dive into the MailKit API, and show you how to create extensions for composing messages, message actions, secure email, and content blocking.<\/p><\/blockquote>\n\n<p><a href=\"https:\/\/www.macrumors.com\/2021\/06\/10\/macos-monterey-mail-app-extensions\/\">Joe Rossignol<\/a>:<\/p>\n<blockquote cite=\"https:\/\/www.macrumors.com\/2021\/06\/10\/macos-monterey-mail-app-extensions\/\">\n<p>In the WWDC session, Apple indicated that older Mail app plug-ins will stop functioning in an unspecified future macOS release.<\/p>\n<\/blockquote>\n<p>Plug-ins still work in Monterey, and <a href=\"https:\/\/c-command.com\/spamsieve\/\">SpamSieve&rsquo;s<\/a> is already in <a href=\"https:\/\/forum.c-command.com\/t\/spamsieve-public-beta-and-macos-12-monterey\/13838\/\">public beta<\/a>.<\/p>\n\n<p>Currently, <a href=\"https:\/\/developer.apple.com\/documentation\/mailkit\">MailKit&rsquo;s<\/a> functionality is very <a href=\"https:\/\/developer.apple.com\/forums\/tags\/mail-extensions\">limited<\/a>. Unless it&rsquo;s expanded in a future version, I think a lot of plug-ins will not be able to make the transition to extensions, a loss to both their users and developers.<\/p>\n\n<p>For SpamSieve, I&rsquo;m cautiously optimistic about extensions. In theory, the current Monterey API is sufficient to implement the core SpamSieve functionality, though implementing some of the more advanced features would require API changes (FB9176051, FB9176075, FB9176097). I say, &ldquo;in theory,&rdquo; because MailKit in the Monterey developer beta doesn&rsquo;t work as designed\/documented. Extensions are supposed to be able to access the <a href=\"https:\/\/developer.apple.com\/documentation\/mailkit\/memessage\/3816034-rawdata\">raw data<\/a> of the message, but currently they receive either incomplete data (FB9175977) or none at all (FB9176011).<\/p>\n\n<p>This takes me back to why I wrote a Mail plug-in <a href=\"https:\/\/c-command.com\/blog\/2004\/01\/26\/spamsieve-2-1-2\/\">in the first place<\/a>. I had resisted doing so because I didn&rsquo;t want to rely on an unsupported private API. But the reason I ended up making a plug-in is that the official API (AppleScript rule actions) was buggy. The private API ended up being more reliable and faster. And I&rsquo;ve even been able to patch Mail to fix some (FB7035263) but not all (FB7145734) of Mail&rsquo;s AppleScript bugs and to tweak the interface to make it more readable.<\/p>\n\n<p>The private API has proven amazingly stable. I&rsquo;ve always tried to make minimal hooks into Mail, and so the updates needed due to Mail code changes have been minor. The main hurdles have been unrelated to the API itself:<\/p>\n\n<ul>\n<li><p>When Apple sandboxed Mail, which meant that the plug-in could no longer communicate with the SpamSieve app via AppleScript. This required developing a new communication mechanism, making it <a href=\"https:\/\/mjtsai.com\/blog\/2017\/11\/13\/app-nap-automatic-termination-and-zombies-apps\/\">zombie-proof<\/a>, and making a new way to launch the app when needed.<\/p><\/li>\n<li><p>The <a href=\"https:\/\/c-command.com\/spamsieve\/help\/why-does-spamsieve-alwa\">compatibility UUID<\/a> policy, where instead of developers testing with new versions of Mail and updating their plug-ins as necessary, each new version of Mail requires each plug-in to be updated, even though most plug-ins don&rsquo;t actually break due to minor Mail updates.<\/p><\/li>\n<li><p>All the <a href=\"https:\/\/c-command.com\/spamsieve\/help\/security-privacy-acce\">privacy<\/a> changes in macOS 10.14 and later. Each subsequent version has added more hurdles to <a href=\"https:\/\/c-command.com\/spamsieve\/help\/enabling-and-updating-t\">installing<\/a> and using plug-ins, making installation and updates more complicated, and various system bugs can get in the way and require obscure <a href=\"https:\/\/c-command.com\/spamsieve\/help\/resetting-mail-s-privat\">reset procedures<\/a>.<\/p><\/li>\n<li><p>Issues related to code signing and notarization. Some versions of Mail require that plug-ins be signed. Some require that they <em>not<\/em> be signed. In some cases, the signing and installation location depend on where the user&rsquo;s home folder is located.<\/p><\/li>\n<\/ul>\n\n<p>So, while I&rsquo;m excited to be able to build on a public API, I&rsquo;m <em>more<\/em> excited that these <em>other<\/em> issues could potentially all go away, so that installation could be as simple as checking a box in Mail&rsquo;s preferences. This could get the user experience back to what it was like before sandboxing.<\/p>\n\n<p>The main downside of extensions is that, as mentioned, they are limited to only the specific features that Apple has decided to open up. They are paving a naturally worn path, which is great, but they are also prohibiting anyone from walking off of the road. Secondly, since extensions run in an isolated process they are at the mercy of any bugs in Mail itself. Increased security rules out good patches along with bad ones.<\/p>\n\n<p>My plan for SpamSieve is as follows:<\/p>\n<ul>\n<li><p>Keep supporting the current plug-in, since some users will remain on Big Sur and earlier releases for a long time. It will also offer the most extensive feature set, at least on Monterey.<\/p><\/li>\n<li><p>Develop a Mail extension to be ready for the day when plug-ins stop functioning, and to identify any (additional) issues so that they can be reported to Apple well before then.<\/p><\/li>\n<li><p>Develop a migration path from the plug-in to the extension.<\/p><\/li>\n<li><p>Investigate other ways of potentially integrating with Mail in case Apple removes plug-ins before the extensions API is working. I don&rsquo;t expect this to happen, but I&rsquo;ve learned not to <a href=\"https:\/\/mjtsai.com\/blog\/2019\/10\/11\/mail-data-loss-in-macos-10-15\/\">assume<\/a> that <em>any<\/em> bug will get fixed.<\/p><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>Apple: Meet MailKit: the best way to build amazing experiences on top of Mail. MailKit enables apps to easily and securely interact with the Mail app for macOS. We&rsquo;ll deep dive into the MailKit API, and show you how to create extensions for composing messages, message actions, secure email, and content blocking. Joe Rossignol: In [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2021-06-23T20:14:43Z","apple_news_api_id":"e63c59e4-f15f-4bff-a97a-fc5db2858625","apple_news_api_modified_at":"2021-07-07T15:58:30Z","apple_news_api_revision":"AAAAAAAAAAAAAAAAAAAAAA==","apple_news_api_share_url":"https:\/\/apple.news\/A5jxZ5PFfS_-pevxdsoWGJQ","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[2],"tags":[126,159,131,150,905,30,2077,1013,53,372],"class_list":["post-32928","post","type-post","status-publish","format-standard","hentry","category-technology","tag-applemail","tag-applescript","tag-bug","tag-email","tag-extensions","tag-mac","tag-macos-12","tag-private-api","tag-sandboxing","tag-spamsieve"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/32928","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=32928"}],"version-history":[{"count":2,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/32928\/revisions"}],"predecessor-version":[{"id":33058,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/32928\/revisions\/33058"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=32928"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=32928"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=32928"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}