All Projects โ†’ Enough-Software โ†’ enough_mail

Enough-Software / enough_mail

Licence: MPL-2.0 license
IMAP, POP3 and SMTP clients for Dart developers. Contains both low level as well as a high level API.

Programming Languages

dart
5743 projects

Projects that are alternatives of or similar to enough mail

Mailkit
A cross-platform .NET library for IMAP, POP3, and SMTP.
Stars: โœญ 4,477 (+5639.74%)
Mutual labels:  imap, mime, smtp, pop3, pop3-client, mime-parser, smtp-client, imap-client
squirrelmail
๐ŸŒฐ๏ธ๐Ÿฟ๏ธ SquirrelMail GitHub Repository (PHP 7-OK!)
Stars: โœญ 42 (-46.15%)
Mutual labels:  imap, smtp, pop3, pop3-client, smtp-client, imap-client
Neomutt
โœ‰๏ธ Teaching an Old Dog New Tricks -- IRC: #neomutt on irc.libera.chat
Stars: โœญ 2,343 (+2903.85%)
Mutual labels:  mail, imap, mime, smtp, pop3
fs2-mail
asynchronous library for sending and receiving mail via fs2._
Stars: โœญ 39 (-50%)
Mutual labels:  mail, imap, mime, smtp
Excision-Mail
Fullstack, security focused mailserver based on OpenSMTPD for OpenBSD using ansible
Stars: โœญ 108 (+38.46%)
Mutual labels:  mail, imap, smtp, pop3
imail
small mail server
Stars: โœญ 88 (+12.82%)
Mutual labels:  mail, imap, smtp, pop3
Mailu
Insular email distribution - mail server as Docker images
Stars: โœญ 3,151 (+3939.74%)
Mutual labels:  mail, imap, smtp, pop3
Mail
Library to send e-mails over different transports and protocols (like SMTP and IMAP) using immutable messages and streams. Also includes SMTP server.
Stars: โœญ 399 (+411.54%)
Mutual labels:  mail, imap, mime, smtp
skirnir
Skirnir Email Server
Stars: โœญ 31 (-60.26%)
Mutual labels:  mail, imap, smtp
go-simple-mail
Golang package for send email. Support keep alive connection, TLS and SSL. Easy for bulk SMTP.
Stars: โœญ 298 (+282.05%)
Mutual labels:  mail, smtp, smtp-client
ESP-Mail-Client
โšก๏ธArduino Mail Client Library to send, read and get incoming mail notification for ESP32, ESP8266 and SAMD21 devices. The library also supported other Arduino devices using Clients interfaces e.g. WiFiClient, EthernetClient, and GSMClient.
Stars: โœญ 78 (+0%)
Mutual labels:  mail, imap, smtp
Mail
The Hoa\Mail library.
Stars: โœญ 24 (-69.23%)
Mutual labels:  mail, imap, smtp
Vmime
VMime Mail Library
Stars: โœญ 218 (+179.49%)
Mutual labels:  imap, mime, smtp
Mailcow Dockerized
mailcow: dockerized - ๐Ÿฎ + ๐Ÿ‹ = ๐Ÿ’•
Stars: โœญ 4,573 (+5762.82%)
Mutual labels:  mail, imap, smtp
Mailmergelib
MailMergeLib is a mail message client library which provides comfortable mail merge capabilities for text, inline images and attachments, as well as good throughput and fault tolerance for sending mail messages.
Stars: โœญ 97 (+24.36%)
Mutual labels:  mail, mime, smtp
Neutron
Self-hosted server for the ProtonMail client
Stars: โœญ 452 (+479.49%)
Mutual labels:  mail, imap, smtp
Maddy
โœ‰๏ธ Composable all-in-one mail server.
Stars: โœญ 2,800 (+3489.74%)
Mutual labels:  mail, imap, smtp
dokku-posteio
Poste.io plugin for Dokku
Stars: โœญ 27 (-65.38%)
Mutual labels:  imap, smtp, pop3
Hydroxide
A third-party, open-source ProtonMail CardDAV, IMAP and SMTP bridge
Stars: โœญ 578 (+641.03%)
Mutual labels:  mail, imap, smtp
Rainloop Webmail
Simple, modern & fast web-based email client
Stars: โœญ 3,618 (+4538.46%)
Mutual labels:  mail, imap, smtp

IMAP, POP3 and SMTP clients for Dart and Flutter email developers.

Available under the commercial friendly MPL Mozilla Public License 2.0.

Installation

Add this dependency your pubspec.yaml file:

dependencies:
  enough_mail: ^2.1.1

The latest version or enough_mail is enough_mail version.

API Documentation

Check out the full API documentation at https://pub.dev/documentation/enough_mail/latest/

High Level API Usage

The high level API abstracts away from IMAP and POP3 details, reconnects automatically and allows to easily watch a mailbox for new messages. A simple usage example for using the high level API:

import 'dart:io';
import 'package:enough_mail/enough_mail.dart';

String userName = 'user.name';
String password = 'password';

void main() async {
  await mailExample();
}


/// Builds a simple example message
MimeMessage buildMessage() {
  final builder = MessageBuilder.prepareMultipartAlternativeMessage(
    plainText: 'Hello world!',
    htmlText: '<p>Hello world!</p>',
  )
    ..from = [MailAddress('Personal Name', '[email protected]')]
    ..to = [
      MailAddress('Recipient Personal Name', '[email protected]'),
      MailAddress('Other Recipient', '[email protected]')
    ];
  return builder.buildMimeMessage();
}

/// Builds an example message with attachment
Future<MimeMessage> buildMessageWithAttachment() async {
  final builder = MessageBuilder()
    ..from = [MailAddress('Personal Name', '[email protected]')]
    ..to = [
      MailAddress('Recipient Personal Name', '[email protected]'),
      MailAddress('Other Recipient', '[email protected]')
    ]
    ..addMultipartAlternative(
      plainText: 'Hello world!',
      htmlText: '<p>Hello world!</p>',
    );
  final file = File.fromUri(Uri.parse('file://./document.pdf'));
  await builder.addFile(file, MediaSubtype.applicationPdf.mediaType);
  return builder.buildMimeMessage();
}

/// High level mail API example
Future<void> mailExample() async {
  final email = '$userName@$domain';
  print('discovering settings for  $email...');
  final config = await Discover.discover(email);
  if (config == null) {
    // note that you can also directly create an account when
    // you cannot auto-discover the settings:
    // Compare the [MailAccount.fromManualSettings]
    // and [MailAccount.fromManualSettingsWithAuth]
    // methods for details.
    print('Unable to auto-discover settings for $email');
    return;
  }
  print('connecting to ${config.displayName}.');
  final account =
      MailAccount.fromDiscoveredSettings('my account', email, password, config);
  final mailClient = MailClient(account, isLogEnabled: true);
  try {
    await mailClient.connect();
    print('connected');
    final mailboxes =
        await mailClient.listMailboxesAsTree(createIntermediate: false);
    print(mailboxes);
    await mailClient.selectInbox();
    final messages = await mailClient.fetchMessages(count: 20);
    messages.forEach(printMessage);
    mailClient.eventBus.on<MailLoadEvent>().listen((event) {
      print('New message at ${DateTime.now()}:');
      printMessage(event.message);
    });
    await mailClient.startPolling();
    // generate and send email:
    final mimeMessage = buildMessage();
    await mailClient.sendMessage(mimeMessage);
  } on MailException catch (e) {
    print('High level API failed with $e');
  }
}

Low Level Usage

A simple usage example for using the low level API:

import 'dart:io';
import 'package:enough_mail/enough_mail.dart';

String userName = 'user.name';
String password = 'password';
String imapServerHost = 'imap.domain.com';
int imapServerPort = 993;
bool isImapServerSecure = true;
String popServerHost = 'pop.domain.com';
int popServerPort = 995;
bool isPopServerSecure = true;
String smtpServerHost = 'smtp.domain.com';
int smtpServerPort = 465;
bool isSmtpServerSecure = true;

void main() async {
  await discoverExample();
  await imapExample();
  await smtpExample();
  await popExample();
  exit(0);
}

Future<void> discoverExample() async {
  var email = '[email protected]';
  var config = await Discover.discover(email, isLogEnabled: false);
  if (config == null) {
    print('Unable to discover settings for $email');
  } else {
    print('Settings for $email:');
    for (var provider in config.emailProviders) {
      print('provider: ${provider.displayName}');
      print('provider-domains: ${provider.domains}');
      print('documentation-url: ${provider.documentationUrl}');
      print('Incoming:');
      print(provider.preferredIncomingServer);
      print('Outgoing:');
      print(provider.preferredOutgoingServer);
    }
  }
}

/// Low level IMAP API usage example
Future<void> imapExample() async {
  final client = ImapClient(isLogEnabled: false);
  try {
    await client.connectToServer(imapServerHost, imapServerPort,
        isSecure: isImapServerSecure);
    await client.login(userName, password);
    final mailboxes = await client.listMailboxes();
    print('mailboxes: $mailboxes');
    await client.selectInbox();
    // fetch 10 most recent messages:
    final fetchResult = await client.fetchRecentMessages(
        messageCount: 10, criteria: 'BODY.PEEK[]');
    for (final message in fetchResult.messages) {
      printMessage(message);
    }
    await client.logout();
  } on ImapException catch (e) {
    print('IMAP failed with $e');
  }
}

/// Low level SMTP API example
Future<void> smtpExample() async {
  final client = SmtpClient('enough.de', isLogEnabled: true);
  try {
    await client.connectToServer(smtpServerHost, smtpServerPort,
        isSecure: isSmtpServerSecure);
    await client.ehlo();
    if (client.serverInfo.supportsAuth(AuthMechanism.plain)) {
      await client.authenticate('user.name', 'password', AuthMechanism.plain);
    } else if (client.serverInfo.supportsAuth(AuthMechanism.login)) {
      await client.authenticate('user.name', 'password', AuthMechanism.login);
    } else {
      return;
    }
    final builder = MessageBuilder.prepareMultipartAlternativeMessage(
      plainText: 'hello world.',
      htmlText: '<p>hello <b>world</b></p>',
    )
      ..from = [MailAddress('My name', '[email protected]')]
      ..to = [MailAddress('Your name', '[email protected]')]
      ..subject = 'My first message';
    final mimeMessage = builder.buildMimeMessage();
    final sendResponse = await client.sendMessage(mimeMessage);
    print('message sent: ${sendResponse.isOkStatus}');
  } on SmtpException catch (e) {
    print('SMTP failed with $e');
  }
}

/// Low level POP3 API example
Future<void> popExample() async {
  final client = PopClient(isLogEnabled: false);
  try {
    await client.connectToServer(popServerHost, popServerPort,
        isSecure: isPopServerSecure);
    await client.login(userName, password);
    // alternative login:
    // await client.loginWithApop(userName, password); // optional different login mechanism
    final status = await client.status();
    print(
        'status: messages count=${status.numberOfMessages}, messages size=${status.totalSizeInBytes}');
    final messageList = await client.list(status.numberOfMessages);
    print(
        'last message: id=${messageList?.first?.id} size=${messageList?.first?.sizeInBytes}');
    var message = await client.retrieve(status.numberOfMessages);
    printMessage(message);
    message = await client.retrieve(status.numberOfMessages + 1);
    print('trying to retrieve newer message succeeded');
    await client.quit();
  } on PopException catch (e) {
    print('POP failed with $e');
  }
}

void printMessage(MimeMessage message) {
  print('from: ${message.from} with subject "${message.decodeSubject()}"');
  if (!message.isTextPlainMessage()) {
    print(' content-type: ${message.mediaType}');
  } else {
    final plainText = message.decodeTextPlainPart();
    if (plainText != null) {
      final lines = plainText.split('\r\n');
      for (final line in lines) {
        if (line.startsWith('>')) {
          // break when quoted text starts
          break;
        }
        print(line);
      }
    }
  }
}

Related Projects

Check out these related projects:

Miss a feature or found a bug?

Please file feature requests and bugs at the issue tracker.

Contribute

Want to contribute? Please check out contribute. This is an open-source community project. Anyone, even beginners, can contribute.

This is how you contribute:

  • Fork the enough_mail project by pressing the fork button.
  • Clone your fork to your computer: git clone github.com/$your_username/enough_mail
  • Do your changes. When you are done, commit changes with git add -A and git commit.
  • Push changes to your personal repository: git push origin
  • Go to enough_mail and create a pull request.

Thank you in advance!

Features

Base standards

  • โœ… IMAP4 rev1 support
  • โœ… SMTP support
  • โœ… POP3 support
  • โœ… MIME parsing and generation support

IMAP extensions

The following IMAP extensions are supported:

SMTP Extensions

The following SMTP extensions are supported:

Security

The following security extensions are supported:

  • โœ… Partial signing of messages using DKIM

Supported encodings

Character encodings:

  • ASCII (7bit)
  • UTF-8 (uft8, 8bit)
  • ISO-8859-1 (latin-1)
  • ISO-8859-2 - 16 (latin-2 - 16)
  • Windows-1250, 1251, 1252, 1253, 1254 and 1256
  • GB-2312, GBK, GB-18030, Chinese, CSGB-2312, CSGB-231280, CSISO-58-GB-231280, ISO-IR-58, X-Mac-ChineseSimp
  • Big5
  • KOI8-r and KOI8-u

Transfer encodings:

To do

Develop and Contribute

  • To start check out the package and then run dart run test to run all tests.
  • Public facing library classes are in lib, lib/imap and lib/smtp.
  • Private classes are in lib/src.
  • Test cases are in test.
  • Please file a pull request for each improvement/fix that you are create - your contributions are welcome.
  • Check out https://github.com/enough-Software/enough_mail/contribute for good first issues.
  • When changing model files, re-run the code generation by calling flutter pub run build_runner build --delete-conflicting-outputs.

License

enough_mail is licensed under the commercial friendly Mozilla Public License 2.0.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].