Socket
Socket
Sign inDemoInstall

capacitor-email-composer

Package Overview
Dependencies
2
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    capacitor-email-composer

E-Mail Composer Plugin for Capacitor


Version published
Weekly downloads
1.3K
decreased by-27.63%
Maintainers
1
Install size
38.2 kB
Created
Weekly downloads
 

Changelog

Source

6.0.0 (2024-04-18)

⚠ BREAKING CHANGES

  • Starting with version 6.X, Capacitor 6 is required

Features

Readme

Source

Capacitor E-Mail Composer

Maintenance npm

This Plugin is used to open a native E-Mail Composer within your Capacitor App.

Table of Content

Install

npm install capacitor-email-composer
npx cap sync

Attachments

You can add attachments to the draft mail by using the attachments option in the open(...) method. Every attachment needs a type and a path. If you are adding a base64 type attachment, you also need to set the name:

Device Storage

The path to the files must be defined absolute from the root of the file system. On Android the user has to allow the app first to read from external storage!

import { EmailComposer } from 'capacitor-email-composer'

EmailComposer.open({
  attachments: [{
    type: 'absolute',
    path: 'storage/sdcard/icon.png' // Android
  }]
})

Native resources

Each app has a resource folder, e.g. the res folder for Android apps or the Resource folder for iOS apps. The following example shows how to attach the app icon from within the app's resource folder.

import { EmailComposer } from 'capacitor-email-composer'

EmailComposer.open({
  attachments: [{
    type: 'resource',
    path: 'icon.png'
  }]
})

Assets

The path to the files must be defined relative from the root of the mobile web app assets folder, which is located under the build folder.

import { EmailComposer } from 'capacitor-email-composer'

EmailComposer.open({
  attachments: [{
    type: 'asset',
    path: '/icon/favicon.png' // starting slash is important
  }]
})

Base64

The code below shows how to attach a base64 encoded image which will be added as an image. You must set a name.

import { EmailComposer } from 'capacitor-email-composer'

EmailComposer.open({
  attachments: [{
    type: 'base64',
    path: 'iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6...',
    name: 'icon.png' // this is required
  }]
})

API

hasAccount()

hasAccount() => Promise<HasAccountResult>

Checks if the User can send a Mail iOS: Check if the current Device is configured to send mail Android: Currently does nothing

Returns: Promise<HasAccountResult>

Since: 1.0.0


open(...)

open(options?: OpenOptions | undefined) => Promise<void>

Open the E-Mail Composer

ParamTypeDescription
optionsOpenOptionsoptional Options to prefill the E-Mail

Since: 1.0.0


Interfaces

HasAccountResult
PropTypeSince
hasAccountboolean1.0.0
OpenOptions
PropTypeDescriptionSince
tostring[]email addresses for TO field1.0.0
ccstring[]email addresses for CC field1.0.0
bccstring[]email addresses for BCC field1.0.0
subjectstringsubject of the email1.0.0
bodystringemail body1.0.0
isHtmlbooleanindicates if the body is HTML or plain text (primarily iOS)1.0.1
attachmentsAttachment[]attachments that are added to the mail file paths or base64 data streams1.2.0
Attachment
PropTypeDescriptionSince
pathstringThe path of the attachment. See the docs for explained informations.1.2.0
type'absolute' | 'resource' | 'asset' | 'base64'The type of the attachment. See the docs for explained informations.1.2.0
namestringThe name of the attachment. See the docs for explained informations. Required for base64 attachements.1.2.0

Changelog

The full Changelog is available here

Troubleshooting

TransactionTooLargeException

When sharing data between two applications, the Android OS might throw this exception for several reasons, for example if the file is too large. Read more here about how to work around this problem.

Keywords

FAQs

Last updated on 18 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc