Mail Extensions

RSS for tag

Use Mail Extensions for composition, message actions, secure email, and content blocking in the Mail app.

Posts under Mail Extensions tag

26 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

macOS Mail app crashes on startup, after playing around with Mailkit
I was playing around with Mailkit. I wanted to extract some info, and show a notification when an email arrives. I copied some code that looked alright for notifications and added it to the defailt MailKit template. I ran it, enabled the extension, sent myself an email and.... Mail app crashes I restart the Mail app, and it instantly crashes on launch. I try to comment out the notification code that i added, compile it and restart the Mail app, and it still crashes. Any help for getting my Mail app back to work would be appreciated! Here is the exact code that made this happen. Don't run it locally unless you want your Mail app to no longer work. import MailKit import UserNotifications class MessageActionHandler: NSObject, MEMessageActionHandler {   static let shared = MessageActionHandler()       func decideAction(for message: MEMessage, completionHandler: @escaping (MEMessageActionDecision?) -> Void) {     // The action to take on the message, if any.     var action: MEMessageActionDecision? = nil           // Check if the subject of the message contains the word Mars.     // If it does, specify an action to set the background color to red.     if message.subject.contains("Mars") {       action = MEMessageActionDecision.action(.setBackgroundColor(.red))     }           let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 1, repeats: false)     var content = UNMutableNotificationContent()      content.title = "Message1"          content.subtitle = "subtitle"          content.body = "body"          content.sound = UNNotificationSound.default          var request = UNNotificationRequest(identifier: UUID().uuidString , content: content, trigger: trigger)          UNUserNotificationCenter.current().add(request)           // Always call the completion handler, passing the action     // to take, or nil if there's no action.     completionHandler(action)   } }
3
1
1.8k
Oct ’23
MailKit extensionViewController(messageContext:) nil context?
In Mail Kit, MEMessageSecurityHandler.extensionViewController(messageContext:)'s context is always nil. Any idea why? class MessageSecurityHandler: NSObject, MEMessageSecurityHandler { func extensionViewController(messageContext context: Data) -> MEExtensionViewController? { let controller = ExampleSigningViewController.sharedInstance controller.msgContext = context // nil ??? why? return controller } I thought it had to do with the MEDecodedMessage.context returned in decodedMessage(forMessageData:) but changing returned the context below still results in the above giving an empty Data. func decodedMessage(forMessageData data: Data) -> MEDecodedMessage? { MEDecodedMessage( data: data, securityInformation: MEMessageSecurityInformation( signers: [], isEncrypted: true, signingError: nil, encryptionError: nil), context: data, // extensionViewController(messageContext:)'s context is still empty banner: nil) Env: macOS Ventura 13.4.1 (c) (22F770820d) Mail Version 16.0 (3731.600.7) Xcode 14.2
1
0
438
Jul ’23
Mail Kit MEMessageSecurityHandler causing slow message loading?
My app's Mail Extension uses the MEMessageSecurityHandler and its decoding functions but opening various emails is noticeably slower, sometimes taking 3-5s, especially on emails with attachments. Specifically, the time it takes from selecting an email from the list to the email body/contents to show up on the right panel is slow, even showing "loading" with the spinner icon. In comparison, when I disable the Mail Extension, emails open in less than a second as expected. Curiously, the "Build Mail app extensions" WWDC sample project seems to have the exact same issue despite having minimal functionality (passes through the mime data without doing any processing on it). Any idea? Env: macOS Ventura 13.4.1 (c) (22F770820d) Mail Version 16.0 (3731.600.7) Xcode 14.2
0
0
408
Jul ’23
Legacy mail plugins in Mac OS Sonoma
Hi, In our organisation, we create and ship a plug-in for the MacOS Mail app along with our software package. We have heard that mail plugins are not supported in Mac OS Sonoma any more. https://www.macrumors.com/2023/06/14/macos-sonoma-drops-legacy-mail-app-plug-ins/ Can anyone tell us more details about what changed, what is its impact and any way to achieve similar functionality as the mail plugins offer, going forward. We read that mailkit extensions are a new thing, we could also use any heads up on its capabilities and limitations (if known). Thanks, Tathagata
5
0
1.8k
Oct ’23
Forcing email encryption with mailkit extensions
I am looking into mail kit extensions and I can see that a security handler extension is the recommended way to offer encryption functionality for emails, however if user chooses to click the padlock icon in top right side of compose window, he can opt out of encryption and the security handler encode method is not called. Is there a way to force and mandate that user cannot opt out of encryption and a security handler's encode method is always called by Mail? My objective is actually to be able to inspect every mail attachment and depending on my business logic, I want to encrypt some of the mail attachments. So I need to make sure my security handler's encode method is called, always. Any other approach for achieving the same is also welcome.
0
0
463
Sep ’23
Smart Mailbox not working with Gmail on Apple Mail - resets to no mailbox selected
I'm trying to sync Gmail with the Apple Mail client and setup a Smart Mailbox of important emails that are unread. The Gmail emails sync correctly, in various folders as on Gmail. However, when I try to create a smart mailbox, they don't filter in and when you go to edit that smart mailbox, the filters reset. See images below: Image 1: Smart Mailbox Settings Image 2: Resets to 'No mailbox selected' after clicking ok (above) Image 3: The Gmail mails are syncing and filtering correctly, as on Gmail. The smart mailbox works for iCloud accounts though and Apple support wasn't helpful. They said it's Google's problem (even though that doesn't make sense) and even refused to create a ticket for further investigation. Google says that since the emails are syncing and filtering, the problem isn't at their end, it is with the way the Apple Mail client works (and that makes sense). Can anyone please help me with a fix here?
1
0
650
Oct ’23
Question on Mailkit API
Hi, So far in my knowledge of the Mailkit API, a security handler’s encode method is the only place I can alter the RFC 822 data of an email (https://developer.apple.com/documentation/mailkit/memessageencoder/3882902-encode), Any other interface method that gives access to the message data gives a read only access. Can Please confirm if the same understanding is incorrect? Encode method, as the below documentation claims, is supposed to be called once, when the message is sent, but I can see that my extension’s encode method is being called several times during composing of an email. Is this a bug? /// @brief This is invoked when an outgoing message is sent. The supplied @c message will contain the email address of the sender, the recipient email addresses, and the message data being sent. The completion handler should be called with the @c result of applying any encoding if needed based on @c shouldSign and @c shouldEncrypt. If the @c result is not encrypted or signed and does not have any errors, it is assumed the message did not need a signature or encryption applied. In this case the @c data for the result will be ignored. /// @param message - The outgoing message to apply any security mechanisms on. /// @param composeContext - @c MEComposeContext instance which corresponds to the @c message being composed. (void)encodeMessage:(MEMessage *)message composeContext:(MEComposeContext *)composeContext completionHandler:(void (^)(MEMessageEncodingResult *result))completionHandler; I also noticed that mailComposeSessionDidBegin from ComposeSessionHandler is getting called but mailComposeSessionDidEnd isn't when I close the compose window of an email or hit send button. Is this also a bug?
0
0
392
Oct ’23
Creating headers in Apple Mail using AppleScript
My grand plan is to have a rule in Apple Mail that automatically adds a custom header to each message. This rule would be last and each of the rules before that last rule would check for the presence of this custom header and therefore no longer work for incoming mail. So the plan is to have a small AppleScript that adds this header but I am running into a block which hopefully someone can help we with. I have the following pieces of code: tell application "Mail" activate set myHeader to make new header with properties {name:"X-MySecretHeader", content:"It's been set"} end The last statement fails with the following error: Mail got an error: Can’t make or move that element into that container. I then changed the code slightly: tell application "Mail" activate set theMessage to get item 1 of (get selection) set theHeaders to headers of theMessage set myHeader to duplicate item -1 of theHeaders end Mail got an error: Headers can not be copied. That last error seems to indicate that I'm trying to do something which cannot be done. I have also tried to do this in a tell block to theMessage but that did not change anything. Anyone has an idea?
0
0
468
Dec ’23
React Native - iOS - open iMessages Share Extension
I am creating an app where i am opening the direct share extension in app for different apps like instagram, snapchat and whatsapp. It is working fine i know there share extension bundle id and it open perfectly. I also need to open the iMessages share extension in app i have found the bundle id of iMessage share extension it is com.apple.UIKit.activity.Message but when i try to open it got error extension not found. Any one have any idea how i can find the right bundle if for iMessage share extension ? I am using an iOS SPM package LNExtensionExecutor and create a bridge between React Native and this native package.
0
0
564
Jan ’24
Proton Mail & Apple Mail.app Mailbox Issues
I'm subscribed to Proton Mail. Their system has my Mail.app client showing nothing in the Inbox while All mail has unread messages. Not sure how this works, and Proton blames it on the client application. With Mail.app closed, I head to the Proton web interface, where it currently shows 9 in Inbox, and 9 in All Mail. So Proton seems to be legit, and Mail.app screws this up somehow. How can I fix this? Cheers
0
0
340
Jan ’24
Mail App shows outdated error popup
We have a MailExtension using new Apple MailKit API. The extension returns an error from the SecurityHandler's Encode Method based on certain conditions and If an error is reported during mail send 3/4 times, even after user performed a corrective action and hits send again, the same error is is shown by Mail again for couple more times. The attached sample mail extension project returns an error after hitting send if subject line of the mail is “Show Alert”. If we repeat the error 3/4 times then even after changing the subject line the error is reported once or twice more. it is an Apple issue as per our investigation. After the subject line is changed in the mail, each time security handler’s encodeMessage is called, we return it successfully and no error is returned to Apple. Still the old error pop-up appears. I think this is a gap in sync between the remote process that loads the extension and actual Mail.app process. It takes a bit of time to reflect the status of encoding to Mail.app from the remote helper process. This is a timing issue, depends on how fast you keep bombarding the Send. After making the correction of the erroneous condition (in this sample, the subject line) if you wait for ten seconds and then hit ‘Send’ the issue doesn't happen. which suggests its a timing sync issue at Apple end. Code Sample Anyone else seeing this?
0
0
308
Feb ’24
mailto: URL handling in MacOS Mail.app
Hi, I'm working on a series of scripts and utilities that process logs and generate pre-composed email reports as a consequence, and wanted to use the open "mailto:address?subject=my subject&body=..." to do so from the scripting. to, cc, bcc, subject, and body are all obvious attributes, but what others are handled? Emails are typically sent from a joint mail address, not the user's primary (default) mail account (but one that is also locally provisioned in Mail.app). So I'd like to force the from=address attribute as well. And the messages should be text/plain, not multipart, and the charset of us-ascii. Where can I find the detailed handling on mailto: URL's in MacOS? RFC-6068 is unfortunately a guideline, and doesn't flesh out many requisites. Thanks
0
1
486
Mar ’24