Skip to content

ErickMaeda/react-native-email-action

Repository files navigation

React Native Email Action

npm version Downloads

A simple and customized way to open email linking (Best option for iOS that will ask you what email app you can use, if installed)

Demo (iOS)

Alt Text

Installation

yarn add react-native-email-action

iOS Only

After iOS 9+, you need to add this information keys on Info.plist

<key>LSApplicationQueriesSchemes</key>
<array>
  <string>message</string>
  <string>ms-outlook</string>
  <string>googlegmail</string>
</array>

Usage

import { sendEmail } from 'react-native-email-action';

const options = {
  to: 'erick.maeda26@gmail.com',
  subject: 'Very important!',
  body: 'Verify your email fast!',
};
sendEmail(options);

Configuring Available Email Apps

By default, the library checks for Mail, Outlook, and Gmail. You can customize which email apps are available by using the configureEmailApps function:

import { sendEmail, configureEmailApps } from 'react-native-email-action';

// Enable specific email apps
configureEmailApps(['mail', 'gmail', 'outlook', 'spark', 'airmail']);

// Or pass appIds directly to sendEmail for one-off usage
sendEmail({
  to: 'user@example.com',
  subject: 'Subject',
  body: 'Body',
  appIds: ['gmail', 'outlook', 'spark'],
});

Available Options to sendMail

description type required
to Email to destination string Y
subject Email Subject string Y
body Email Content string Y
cc Email CC array N
bcc Email BCC array N

Available email apps

iOS (If installed)

  • Mail
  • Gmail
  • Outlook
  • Spark
  • Airmail
  • Superhuman
  • Yahoo Mail
  • Fastmail
  • ProtonMail

You can use any of these app IDs when calling configureEmailApps(): mail, gmail, outlook, spark, airmail, superhuman, ymail, fastmail, protonmail

Android

  • All the apps installed.

iOS Configuration

After iOS 9+, you need to add the URL schemes for the email apps you want to support in your Info.plist:

<key>LSApplicationQueriesSchemes</key>
<array>
  <string>message</string>
<!-- iOS configuration details are consolidated below -->
  <string>ms-outlook</string>
  <string>googlegmail</string>
  <string>readdle-spark</string>
  <string>airmail</string>
</array>

Roadmap

API

  • sendEmail(options): Opens the email composer. On iOS, shows an action sheet listing available apps based on configureEmailApps() or options.appIds.
  • configureEmailApps(appIds): Sets the default list of email apps to check on iOS. Use app IDs from the list below.
  • Add other app emails for iOS ✅ Done! (configurable)
  • Add attachment option

About

A simple and customized way to open email linking (Best option for iOS that will ask you what email provider you can use)

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors