본문 바로가기
Development Solutions/Flutter & Dart

[flutter_email_sender] How to implement email sending in a flutter project (플러터 프로젝트에서 이메일 보내기 구현하는 방법)

by Dev Diary Hub 2022. 8. 29.
반응형

flutter_email_sender

How to implement email sending in a flutter project

(플러터 프로젝트에서 이메일 보내기 구현하는 방법)

 

 

우선 프로젝트에 flutter_email_sender 라이브러리를 설치한다. (First of all, the flutter email _ sender to install the library.)

dependencies:
  flutter_email_sender: ^5.1.0

 

소스코드에서는 아래와 같이 라이브러리를 import한다. (Source code import the library as follows.)

import 'package:flutter_email_sender/flutter_email_sender.dart';

 

이메일 보내기 예제는 아래와 같다. await를 사용해야하니 구현에 유의하자. (An example is as follows to the email.Let's shall be used, so pay attention to the implementation of the await.)

final Email email = Email(
  body: 'Email body',
  subject: 'Email subject',
  recipients: ['example@example.com'],
  cc: ['cc@example.com'],
  bcc: ['bcc@example.com'],
  attachmentPaths: ['/path/to/attachment.zip'],
  isHTML: false,
);

await FlutterEmailSender.send(email);

 

안드로이드11 이상 버전의 경우, 추가적인 작업을 해줘야한다.

AndroidManifest.xml을 아래와 같이 수정한다.

 

(For Android 11 and later versions, additional work needs to be done.

Modify AndroidManifest.xml as follows.)

<manifest package="com.mycompany.myapp">
  <queries>
    <intent>
      <action android:name="android.intent.action.SENDTO" />
      <data android:scheme="mailto" />
    </intent>
  </queries>
</manifest>

 

 

Thank you for reading it!

반응형