mailer2 1.2.3

  • Installing
  • Versions
  • 91


Note: this is a temporary fork of Kai Sellgren's Mailer ( for aggressive support of Reply-To and List-Unsubscribe

Who Uses

  • Quire - a simple, collaborative, multi-level task management tool.


Mailer is an easy to use library for composing and sending emails in Dart.

Mailer supports file attachments, HTML emails and multiple transport methods.


  • Plaintext and HTML emails
  • Unicode support
  • Attachments
  • Secure (filters and sanitizes all fields context-wise)
  • Use any SMTP server like Gmail, Live, SendGrid, Amazon SES
  • SSL/TLS support
  • Pre-configured services (Gmail, Live,, etc.). Just fill in your username and password.

Filing bug tickets

Please call printDebugInformation() from the mailer package and send the output along with your helpful explanation of what went wrong.


  • All possible SMTP authentication methods (now just LOGIN)
  • Sendmail
  • Stream attachments
  • String-based attachments


Sending an email with SMTP

In this example we send an email using a Gmail account.

import 'package:mailer/mailer.dart';

main() {
  // If you want to use an arbitrary SMTP server, go with `new SmtpOptions()`.
  // This class below is just for convenience. There are more similar classes available.
  var options = new GmailSmtpOptions()
    ..username = 'your gmail username'
    ..password = 'your gmail password'; // Note: if you have Google's "app specific passwords" enabled,
                                        // you need to use one of those here.
  // How you use and store passwords is up to you. Beware of storing passwords in plain.

  // Create our email transport.
  var emailTransport = new SmtpTransport(options);

  // Create our mail/envelope.
  var envelope = new Envelope()
    ..from = ''
    ..subject = 'Testing the Dart Mailer library'
    ..attachments.add(new Attachment(file: new File('path/to/file')))
    ..text = 'This is a cool email message. Whats up?'
    ..html = '<h1>Test</h1><p>Hey!</p>';

  // Email it.
    .then((envelope) => print('Email sent!'))
    .catchError((e) => print('Error occurred: $e'));


This library is licensed under MIT.


  • Introduce listUnsubscribe
  • Remove replyTo and replyToName


  • Updated for Dart 2, including updating dependency versions.


  • Introduce replyTos
  • Deprecate replyTo and replyToName


  • Remove extra trailing \r\n from messages as some servers may interpret it as an empty command and send back an error code after success code


  • Fix occasional issue with completer already completed. Due to an error with SMTP server closing connection after sending the email.


  • Fix new lines sent to server to be proper \r\n format


  • loosen crypto dependency to '>=0.9.0 <3.0.0' as suggested in the crypto changelog


  • merge crypto util fix and update example
  • upgrade unittest to test and move it to dev_dependencies
  • added OpenMailBoxSmtpOptions
  • improve address parsing and sanitization (from hoylen)
  • cleanup chunkEncodedBytes and associated test
  • update example to allow CC and BCC


  • add simple example/
  • fix pubspec to pull crypto 0.9.0

1.0.0 - Oct 4, 2015

  • initial release

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  mailer2: ^1.2.3

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:mailer2/mailer.dart';
Version Uploaded Documentation Archive
1.2.3 Aug 24, 2018 Go to the documentation of mailer2 1.2.3 Download mailer2 1.2.3 archive
1.2.0+1 Aug 11, 2018 Go to the documentation of mailer2 1.2.0+1 Download mailer2 1.2.0+1 archive
1.2.0 Aug 10, 2018 Go to the documentation of mailer2 1.2.0 Download mailer2 1.2.0 archive
1.1.6 Sep 29, 2017 Go to the documentation of mailer2 1.1.6 Download mailer2 1.1.6 archive
1.1.5 Jul 10, 2017 Go to the documentation of mailer2 1.1.5 Download mailer2 1.1.5 archive
1.1.4 Jun 27, 2017 Go to the documentation of mailer2 1.1.4 Download mailer2 1.1.4 archive
1.1.0+4 Sep 9, 2016 Go to the documentation of mailer2 1.1.0+4 Download mailer2 1.1.0+4 archive
1.1.0+3 Sep 6, 2016 Go to the documentation of mailer2 1.1.0+3 Download mailer2 1.1.0+3 archive
1.1.0+2 Sep 5, 2016 Go to the documentation of mailer2 1.1.0+2 Download mailer2 1.1.0+2 archive
1.1.0+1 Aug 31, 2016 Go to the documentation of mailer2 1.1.0+1 Download mailer2 1.1.0+1 archive

All 13 versions...

Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Dec 5, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.7


Detected platforms: Flutter, other

Platform components identified in package: io.

Health suggestions

Format lib/src/address.dart.

Run dartfmt to format lib/src/address.dart.

Format lib/src/envelope.dart.

Run dartfmt to format lib/src/envelope.dart.

Format lib/src/smtp/smtp_client.dart.

Run dartfmt to format lib/src/smtp/smtp_client.dart.

Maintenance suggestions

Maintain an example.

None of the files in your example/ directory matches a known example patterns. Common file name patterns include: main.dart, example.dart or you could also use mailer2.dart. Packages with multiple examples should use example/


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev <3.0.0
charcode <2.0.0 1.1.2
dart2_constant ^1.0.0 1.0.2+dart2
intl >0.9.0 <1.0.0 0.15.7
logging <1.0.0 0.11.3+2
mime >0.9.0 <1.0.0 0.9.6+2
path >0.9.0 <2.0.0 1.6.2
Dev dependencies
args >0.13.0 <2.0.0
test >0.12.0 <2.0.0