How to send email from a sandboxed Mac OS app?

What is the suggested way - or the needed entitlement - or some such other strategy - to be able to send an eMail from a sandboxed app in MacOSX 10.7+ ?


As best I can tell - it is not possible to invoke sendmail from a sandboxed app - nor is it possible to use a Script Bridge to the Apple MAIL applicaiton.


Any ideas would be greatly appreciated.


Thank you.

Posted on Sep 16, 2012 11:23 AM

Reply
2 replies

Sep 16, 2012 2:28 PM in response to notarysojac

The Apple-approved way would be use NSWorkspace to open a "mail:" URL. That would route the message through the user's e-mail application and allow the user to compose the message. You don't need any entitlement for that. You could use a standard network entitlement and compose and send the message yourself. That would be a fair amount of work and would require your own SMTP configuration. You could invoke sendmail, but you would have to have your own config files for it. Email is a royal pain to configure though. Even if you weren't sandboxed, sending e-mail would still be a royal hassle. Do you have to use e-mail? Do you have to use local e-mail? An easy solution would be to have your app make a request to your own server somewhere that would send the e-mail.

Sep 19, 2012 10:35 AM in response to etresoft

Hi etresoft -


After a little more investigation, I discovered how it is possible to enable the ability to send email from a sandboxed app by way of a "com.apple.security.temporary-exception.apple-events" entitlement array with item of "com.apple.mail".


Of course, like it says, this is a TEMPORARY fix - and that capability could be revoked by Apple at any time.


I also discovered that, via WEBKIT, you can embed a "mailto:" reference in a 'webpage' that is a clickable link such that the User can click on the link and your local MAIL app will open a new message with everything pretty much all filled out. Check out "http://www.mailto.co.uk/" for some examples and inspiration.


My HTML example... slightly different from the image below... but basically the idea...

<a href="mailto:lance@drake.org?cc=lance@vuserland.com&subject=This%20is%20the%20subject&body=This%20is%20the%20body%20of%20the%20emai l">Here's a sample 'Send email' test</a>



User uploaded file


As for the more long-term solution, I think that the APNS Push Notifications will probably fill the bill for me - although, it appears rather complicated to get that capability up and running.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How to send email from a sandboxed Mac OS app?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.