Flutter/外部ライブラリ/メール送信/flutter mailer
提供: 初心者エンジニアの簡易メモ
flutter_mailerとは
直でflutterからメール送信できるライブラリ
公式
https://pub.dev/packages/flutter_mailer
インストール
dependencies: flutter_mailer: ^0.4.1+1
サンプル
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', ],
);
await FlutterMailer.send(mailOptions);
成功するとandroidだとgmailのページがアプリ内で開く。iosだと内製メーラーが開く。
エラーが出てしまう
androidx対応してるライブラリっぽいので、導入側プロジェクトにandroidxが対応しておらずエラーになってた。androidx対応したところ直った。
~/android/app/src/debug/AndroidManifest.xml:22:18-91 Error: Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91 is also present at [androidx.core:core:1.0.2] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory). Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:11:5-34:19 to override. <pre>
