enough_mail_plus 2.2.4 copy "enough_mail_plus: ^2.2.4" to clipboard
enough_mail_plus: ^2.2.4 copied to clipboard

enough_mail - IMAP, POP3, SMTP email library with high/low-level APIs and MIME parsing

example/example.dart

import 'package:enough_mail_plus/enough_mail.dart';

/// Simple example demonstrating basic email discovery and IMAP usage.
void main() async {
  // Auto-discover email settings
  const email = 'user@example.com';
  final config = await Discover.discover(email, isLogEnabled: false);

  if (config == null) {
    print('Unable to discover settings for $email');
    return;
  }

  print('Found settings for $email:');
  for (final provider in config.emailProviders ?? []) {
    print('Provider: ${provider.displayName}');
    print('Domains: ${provider.domains}');
  }

  // IMAP example
  final imapClient = ImapClient(isLogEnabled: false);
  await imapClient.connectToServer('imap.example.com', 993, isSecure: true);
  await imapClient.login('user@example.com', 'password');
  await imapClient.selectInbox();

  final messages = await imapClient.fetchRecentMessages(messageCount: 5);
  for (final message in messages.messages) {
    print('From: ${message.from}');
    print('Subject: ${message.decodeSubject()}');
  }

  await imapClient.logout();

  // SMTP example
  final smtpClient = SmtpClient('example.com', isLogEnabled: false);
  await smtpClient.connectToServer('smtp.example.com', 587, isSecure: false);
  await smtpClient.ehlo();
  if (smtpClient.serverInfo.supportsAuth(AuthMechanism.plain)) {
    await smtpClient.authenticate(
      'user@example.com',
      'password',
      AuthMechanism.plain,
    );
  }

  final builder = MessageBuilder()
    ..from = [const MailAddress('Sender', 'sender@example.com')]
    ..to = [const MailAddress('Recipient', 'recipient@example.com')]
    ..subject = 'Test Email'
    ..text = 'Hello from enough_mail!';

  final message = builder.buildMimeMessage();
  await smtpClient.sendMessage(message);
  print('Email sent successfully!');
}
1
likes
160
points
162
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

enough_mail - IMAP, POP3, SMTP email library with high/low-level APIs and MIME parsing

Repository (GitHub)
View/report issues

Topics

#email #imap #pop3 #smtp #mime

License

MPL-2.0 (license)

Dependencies

basic_utils, collection, crypto, encrypter_plus, enough_convert, intl, json_annotation, pointycastle, synchronized, xml

More

Packages that depend on enough_mail_plus