搜尋套件、儲存庫與 APP 分類

套件詳情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
  • 跨平台相容性
  • 可設定的電子郵件欄位(收件人、主旨、內文)

適合對象

  • 需要電子郵件共享功能的應用程式
  • 基於文件的應用程式
  • 客戶支援整合
  • 報告或分析工具
  • 使用者產生內容分發

使用建議

  • 依賴使用者的預設電子郵件客戶端
  • 沒有使用者互動,無法直接寄送電子郵件
  • 附件大小限制取決於裝置和作業系統
  • 某些設備需要正確的權限
  • 電子郵件的編寫方式在不同平台上可能略有差異

原始 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

所屬分類

原始碼儲存庫

使用此套件的專案