mailer 1.0.0


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()`.

  var options = new GmailSmtpOptions()
    ..username = 'your gmail username'
    ..password = 'your gmail password'; // Note: if you have Google's "app specific passwords" enabled,

  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.

1. Depend on it

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

  mailer: "^1.0.0"

2. Install it

You can install packages from the command line:

$ pub get

Alternatively, your editor might support pub. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:mailer/mailer.dart';


Compose and send emails from Dart. Supports file attachments, HTML emails and multiple transport methods.


Email Kai Sellgren