Interact with third-party iOS mail clients, using custom URL schemes.
Client | URL Scheme | App Store |
---|---|---|
Sparrow | sparrow |
discontinued |
Gmail | googlegmail |
link |
Dispatch | x-dispatch |
link |
Spark | readdle-spark |
link |
Airmail | airmail |
link |
Microsoft Outlook | ms-outlook |
link |
Yahoo Mail | ymail |
link |
Fastmail | fastmail |
link |
ProtonMail | protonmail |
link |
Unfortunately, not all mail clients offer URL schemes to be supported by ThirdPartyMailer
. If you’re aware of another candidate, please let us know.
In Xcode, click on the “File” menu, “Swift Packages”, “Add Package Dependency…”, then enter the URL for this repo: https://github.com/vtourraine/ThirdPartyMailer.git
.
With CocoaPods, simply add ThirdPartyMailer to your Podfile:
pod 'ThirdPartyMailer'
Or, you can manually import the files from the Sources folder.
let clients = ThirdPartyMailClient.clients
Info.plist
file, by adding a LSApplicationQueriesSchemes
array. You can find an example here, or check out the documentation.
if ThirdPartyMailer.isMailClientAvailable(client) {
// ...
}
ThirdPartyMailer.openCompose(client, recipient: "friend@mail.com")
ThirdPartyMailer.openCompose(client, recipient: "friend@mail.com", subject: "Hello", body: "Good morning…", cc: "cc@mail.com", bcc: "bcc@mail.com")
If you don’t specify a client, the openCompose(…)
function will use .systemDefault
, a client defined for the standard mailto:
scheme. By default, it will open Apple Mail, but if the user has selected a custom mail client (iOS 14), it will automatically open it instead.
ThirdPartyMailer.openCompose(recipient: "friend@mail.com")
ThirdPartyMailer is written in Swift 5.0, requires iOS 10.0 and above, Xcode 10.2 and above.
ThirdPartyMailer was created by Vincent Tourraine.
ThirdPartyMailer is available under the MIT license. See the LICENSE.txt file for more info.