パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v3.0.3

flutter_mailer

デバイスにメールを共有 メール - クライアントは複数の添付ファイルをサポートしています

AndroidiOS
30日間ダウンロード
2.9万
いいね数
92
Pub ポイント
160

パッケージをインストール

flutter pub add flutter_mailer

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

Flutter Mailer は、アプリからデバイスのデフォルトメールクライアントに直接メールを共有できる Flutter パッケージです。複数の添付ファイルを含むメールの送信をサポートしており、ドキュメントや画像、その他のファイルを共有するのに最適です。このパッケージは Android および iOS プラットフォームとシームレスに統合され、ネイティブなメールインテントを使用して互換性と信頼性を確保します。事前に指定された受信者、件名、本文、添付ファイルでメール作成画面を開始するプロセスを簡単にします。

用途

  • アプリ内からドキュメントを共有する
  • 添付ファイル付きのサポートチケットを送信する
  • レポートや領収書の配布
  • メールによるユーザーのフィードバックを有効にする
  • アプリでのメールワークフローの自動化

主な機能

  • 複数のファイル添付をサポート
  • Android および iOS でネイティブメールクライアントを使用
  • メール作成のためのシンプルな API
  • クロスプラットフォーム互換性
  • カスタマイズ可能なメールフィールド(送信先、件名、本文)

適している対象

  • メール共有機能を必要とするアプリ
  • ドキュメントベースのアプリケーション
  • カスタマーサポートの統合
  • レポートまたは分析ツール
  • ユーザー生成コンテンツの配信

注意事項

  • ユーザーのデフォルトのメールクライアントに依存しています
  • ユーザーの操作なしでは、直接メールを送信できません
  • 添付ファイルのサイズ制限はデバイスおよびOSに依存します
  • 一部のデバイスでは適切な権限が必要です
  • メールの作成方法は、プラットフォームによってわずかに異なる場合があります

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

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

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト