mailer 2.0.1

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 70

mailer

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

Mailer supports file attachments and HTML emails.

Dart2 support

Support for dart2 has been added in version ^1.2.0

Version ^2.0.0 is a rewrite (it too supports dart1.x and dart2).

Even though the API for ^2.0.0 has slightly changed, most programs will probably continue to work with deprecation warnings.

SMTP definitions

Mailer provides configurations for a few common SMTP servers.

Please create merge requests for missing configurations.

  • Copy lib/smtp_server/gmail.dart to lib/smtp_server/xxx.dart
  • Adapt the code. (See lib/smtp_server.dart for possible arguments)
  • Create a pull request.

In a lot of cases you will find a configuration in legacy.dart

Features

  • 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, Yahoo, Hotmail, etc.). Just fill in your username and password.

TODO HELP WANTED

  • Correct encoding of non ASCII mail addresses.
  • Reintegrate address validation from version 1.*
  • Improve Header types. (see ir_header.dart)
    We should choose the correct header based on the header name.
    Known headers (list-unsubscribe,...) should have their own subclass.
  • Improve documentation.

Examples

Sending an email with SMTP

See gmail example.

import 'dart:io';

import 'package:mailer/mailer.dart';
import 'package:mailer/smtp_server/gmail.dart';

main() async {
  String username = 'username@gmail.com';
  String password = 'password';

  final smtpServer = gmail(username, password);
  
  // Create our message.
  final message = new Message()
    ..from = new Address(username, 'Your name')
    ..recipients.add('destination@example.com')
    ..ccRecipients.addAll(['destCc1@example.com', 'destCc2@example.com'])
    ..bccRecipients.add(new Address('bccAddress@example.com'))
    ..subject = 'Test Dart Mailer library :: 😀 :: ${new DateTime.now()}'
    ..text = 'This is the plain text.\nThis is line 2 of the text part.'
    ..html = "<h1>Test</h1>\n<p>Hey! Here's some HTML content</p>";
  
  final sendReports = await send(message, smtpServer);
  
  // DONE
  
  
  // Let's send another message using a slightly different syntax:
  //
  // Addresses without a name part can be set directly.
  // For instance `..recipients.add('destination@example.com')`
  // If you want to display a name part you have to create an
  // Address object: `new Address('destination@example.com', 'Display name part')`
  // Creating and adding an Address object without a name part
  // `new Address('destination@example.com')` is equivalent to
  // adding the mail address as `String`.
  final equivalentMessage = new Message()
      ..from = new Address(username, 'Your name')
      ..recipients.add(new Address('destination@example.com'))
      ..ccRecipients.addAll([new Address('destCc1@example.com'), 'destCc2@example.com'])
      ..bccRecipients.add('bccAddress@example.com')
      ..subject = 'Test Dart Mailer library :: 😀 :: ${new DateTime.now()}'
      ..text = 'This is the plain text.\nThis is line 2 of the text part.'
      ..html = "<h1>Test</h1>\n<p>Hey! Here's some HTML content</p>";
    
  final sendReports2 = await send(equivalentMessage, smtpServer);
}

License

This library is licensed under MIT.

1.1.4

  • 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

1.1.3

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

1.1.2

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

1.1.1

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

1.1.0

  • 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

1.0.1

  • add simple example/send_gmail.data
  • 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:


dependencies:
  mailer: ^2.0.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. 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';
  
Version Uploaded Documentation Archive
2.0.1 Sep 24, 2018 Go to the documentation of mailer 2.0.1 Download mailer 2.0.1 archive
2.0.0 Sep 20, 2018 Go to the documentation of mailer 2.0.0 Download mailer 2.0.0 archive
1.2.3 Aug 20, 2018 Go to the documentation of mailer 1.2.3 Download mailer 1.2.3 archive
1.2.2 Aug 19, 2018 Go to the documentation of mailer 1.2.2 Download mailer 1.2.2 archive
1.2.1 Aug 17, 2018 Go to the documentation of mailer 1.2.1 Download mailer 1.2.1 archive
1.2.0 Aug 17, 2018 Go to the documentation of mailer 1.2.0 Download mailer 1.2.0 archive
1.1.4 May 26, 2017 Go to the documentation of mailer 1.1.4 Download mailer 1.1.4 archive
1.1.3 May 24, 2017 Go to the documentation of mailer 1.1.3 Download mailer 1.1.3 archive
1.1.2 May 23, 2017 Go to the documentation of mailer 1.1.2 Download mailer 1.1.2 archive
1.1.1 Sep 11, 2016 Go to the documentation of mailer 1.1.1 Download mailer 1.1.1 archive

All 24 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
89
Health:
Code health derived from static analysis. [more]
32
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
70
Learn more about scoring.

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

  • Dart: 2.0.0
  • pana: 0.12.3

Platforms

Detected platforms: unsure

Low code quality prevents platform classification.

Issues and suggestions

Fix platform conflicts.

Low code quality prevents platform classification.

Fix bin/print_data.dart.

Analysis of bin/print_data.dart failed with 4 errors:

line 4 col 8: Target of URI doesn't exist: 'package:args/args.dart'.

line 58 col 1: Undefined class 'ArgResults'.

line 59 col 20: Undefined class 'ArgParser'.

line 87 col 11: Undefined class 'ArgParser'.

Format lib/mailer.dart.

Run dartfmt to format lib/mailer.dart.

Format lib/src/entities/address.dart.

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

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 mailer.dart.

Fix additional 5 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/smtp/capabilities.dart (Run dartfmt to format lib/src/smtp/capabilities.dart.)
  • lib/src/smtp/connection.dart (Run dartfmt to format lib/src/smtp/connection.dart.)
  • lib/src/smtp/internal_representation/ir_content.dart (Run dartfmt to format lib/src/smtp/internal_representation/ir_content.dart.)
  • lib/src/smtp/internal_representation/ir_header.dart (Run dartfmt to format lib/src/smtp/internal_representation/ir_header.dart.)
  • lib/src/smtp/validator.dart (Run dartfmt to format lib/src/smtp/validator.dart.)

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.24.0 <3.0.0
async ^2.0.0 2.0.8
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
Transitive dependencies
collection 1.14.11
Dev dependencies
args ^1.5.0