Search packages, repositories and app categories

Package detailsv3.0.3

flutter_mailer

Share an email to device Email - Client supports multiple Attachments

AndroidiOS
30-day downloads
28.5K
Likes
92
Pub points
160

Install package

flutter pub add flutter_mailer

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

Flutter Mailer is a Flutter package that enables users to share emails directly from their app to the device's default email client. It supports sending emails with multiple attachments, making it ideal for sharing documents, images, or other files. The package integrates seamlessly with Android and iOS platforms, leveraging native email intents to ensure compatibility and reliability. It simplifies the process of initiating an email composition screen with predefined recipients, subject, body, and attachments.

Use cases

  • Sharing documents from within an app
  • Sending support tickets with attachments
  • Distributing reports or receipts
  • Enabling user feedback via email
  • Automating email workflows in apps

Key features

  • Supports multiple file attachments
  • Uses native email clients on Android and iOS
  • Simple API for email composition
  • Cross-platform compatibility
  • Configurable email fields (to, subject, body)

Suitable for

  • Apps needing email sharing functionality
  • Document-based applications
  • Customer support integrations
  • Reporting or analytics tools
  • User-generated content distribution

Considerations

  • Relies on the user's default email client
  • No direct email sending without user interaction
  • Attachment size limits depend on device and OS
  • Requires proper permissions on some devices
  • Email composition may vary slightly across platforms

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

flutter_mailer

pub package

Share email content via device Email Client - supports multiple Attachments

Simple & quick plugin for cross application data sharing of email fields in mobile development.

Flutter Mailer example app

Supports:

  • [x] android
  • [x] ios

Getting Started

Add to your pubspec dependencies, like so:

dependencies:
  flutter:
    sdk: flutter
  flutter_mailer: ^3.0.0

Instantiate mail options as follows:

send email
import 'package:flutter_mailer/flutter_mailer.dart';

...
...

final MailOptions mailOptions = MailOptions(
  body: 'a long body for the email <br> with a subset of HTML',
  subject: 'the Email Subject',
  recipients: ['example@example.com'],
  isHTML: true,
  bccRecipients: ['other@example.com'],
  ccRecipients: ['third@example.com'],
  attachments: [ 'path/to/image.png', ],
);

final MailerResponse response = await FlutterMailer.send(mailOptions);
switch (response) {
  case MailerResponse.saved: /// ios only
    platformResponse = 'mail was saved to draft';
    break;
  case MailerResponse.sent: /// ios only
    platformResponse = 'mail was sent';
    break;
  case MailerResponse.cancelled: /// ios only
    platformResponse = 'mail was cancelled';
    break;
  case MailerResponse.android:
    platformResponse = 'intent was successful';
    break;
  default:
    platformResponse = 'unknown';
    break;
}

note gmail and other apps Might parse HTML out of the body.

[Android] check if app is installed.

use full if you want to send the intent to a specific App. returns false on [IOS]

const GMAIL_SCHEMA = 'com.google.android.gm';

final bool gmailinstalled =  await FlutterMailer.isAppInstalled(GMAIL_SCHEMA);

if(gmailinstalled) {
  final MailOptions mailOptions = MailOptions(
    body: 'a long body for the email <br> with a subset of HTML',
    subject: 'the Email Subject',
    recipients: ['example@example.com'],
    isHTML: true,
    bccRecipients: ['other@example.com'],
    ccRecipients: ['third@example.com'],
    attachments: [ 'path/to/image.png', ],
    appSchema: GMAIL_SCHEMA,
  );
  await FlutterMailer.send(mailOptions);
}

[IOS] check if device has the ability to send email

this package uses MFMailComposeViewController for [IOS] which requires the default mail App. if none is installed you might want to revert to use url_launcher returns false on [Android]


  final bool canSend = await FlutterMailer.canSendMail();

  if(!canSend && Platform.isIos) {
    final url = 'mailto:$recipient?body=$body&subject=$subject';
    if (await canLaunch(url)) {
      await launch(url);
    } else {
      throw 'Could not launch $url';
    }
  }
}

For help getting started with Flutter, view official online documentation.

For help on editing plugin code, view the documentation.

based off of react-native-mail

Categories

Source repository

Projects using this package