Skip to content
CAI
Software that uses CAICheck a score

mikel/mail

62.5

Adequate · 28 September 2026

64.9k

lines of production code

Ruby

primary language

2

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

This system is a Ruby library for parsing, creating, and sending email messages, supporting SMTP delivery, POP3/IMAP retrieval, and multipart MIME structures. It provides robust handling of email headers, encodings, and attachments, with dedicated classes for managing these components according to RFC standards. The library also includes testing utilities, such as RSpec matchers, and various delivery methods for debugging and integration.

How it got here

2008 — Initial Mail library release and stabilization

7 changes.

This period marks the initial release of the Mail library, introducing core functionality for parsing, creating, and sending email messages with improved performance via a Ragel-based parser. The work focused on establishing a robust architecture with dedicated classes for attachments and structured header fields, ensuring strict adherence to RFC standards. Comprehensive test suites were added to verify parsing, encoding, and delivery mechanisms, culminating in the 2.9.0 release with performance optimizations and bug fixes.

2009 — Parser rewrite and delivery expansion

10 changes.

The project replaced its Treetop parser with a high-performance Ragel-based engine and rewrote the encoding subsystem to improve robustness and RFC compliance. This period also introduced new IMAP and POP3 retrievers with search capabilities, added multiple email delivery methods, and established comprehensive test coverage and gem dependencies.

2010–2022 — Parser modernization and testing expansion

8 changes.

The project replaced its Treetop parsing engine with Ragel to improve performance and add UTF-8 support, while simultaneously rewriting multibyte string handling to remove external dependencies. This period also focused on expanding test coverage for network delivery and retrieval methods and introducing new RSpec matchers to facilitate more granular email testing.

Features

Added tools/console for interactive IRB sessions

A new executable script at tools/console has been added to provide a quick IRB session for the Mail library. The script sets up the Bundler environment, attempts to load the byebug gem for debugging capabilities (silently ignoring if unavailable), and initializes the IRB console with completion support.

tools · high confidence

Initial release of the Mail library

This change introduces the core Mail library, providing a Ruby-based solution for parsing, creating, and sending email messages. The library includes support for SMTP delivery with TLS, POP3 retrieval, multipart MIME messages, and various transfer encodings (Base64, Quoted-Printable, UUencode). It replaces the previous Treetop parser with a Ragel-based parser for improved performance and memory usage, and integrates with ActiveSupport for compatibility while maintaining independence for Ruby 1.9+ environments.

lib · high confidence

New RSpec matchers for testing email attachments and delivery details

This change introduces new RSpec matchers in the \lib/mail/matchers\ directory to improve email testing capabilities. The \attachment\_matchers.rb\ file adds \any\_attachment\, \an\_attachment\_with\_filename\, and \an\_attachment\_with\_mime\_type\ matchers, allowing tests to verify specific attachment properties. The \has\_sent\_mail.rb\ file provides a comprehensive \have\_sent\_email\ matcher that supports chaining methods to verify email recipients (to, cc, bcc), subject, body (text and HTML parts), and attachment presence or specifics, enabling more granular assertions on sent emails.

lib/mail/matchers · high confidence

New delivery methods: Exim, File, Logger, and SMTP Connection

The library introduces four new delivery methods for sending or handling emails. You can now deliver mail via the Exim MTA (defaulting to /usr/sbin/exim), write messages to individual files based on recipient addresses using FileDelivery, log messages to a Ruby Logger via LoggerDelivery, or send via an existing open Net::SMTP connection using SMTPConnection. These complement the existing Sendmail and SMTP methods, providing more flexibility for testing, debugging, and specific server integrations.

_lib/mail/network/delivery\methods · high confidence

New rake tasks for corpus verification and Unicode database generation

Added three new files to the rakelib directory to support development and testing workflows. The new \corpus.rake\ task allows users to verify email parsing against an arbitrary directory of email files, saving any failures for inspection. The \generate\_tables\ script enables the regeneration of the Unicode database used for multibyte string handling by downloading and parsing official Unicode data files. Additionally, \ragel.rake\ provides tasks to generate Ruby parsers from Ragel definitions and create visual SVG diagrams of the parser state machines.

rakelib · high confidence

Behavioural changes

2 commits (0 fixes) modifying lib/mail/values

A change to existing behaviour in lib/mail/values — 2 commits, 1 file.

lib/mail/values · medium confidence · unverified

Introduce dedicated Mail::AttachmentsList class for attachment management

The library now uses a dedicated \Mail::AttachmentsList\ class to manage email attachments, replacing the previous implicit handling. This class provides an array-like interface with specific methods to filter attachments by disposition (e.g., \inline\), access them by filename or index, and add new attachments via hash parameters or raw data. It automatically handles MIME type detection, filename encoding, and content transfer encoding guessing when adding files, ensuring that attachments are correctly structured within the message parts list.

lib/mail · high confidence

Introduce new IMAP and POP3 email retrievers with find and delete capabilities

This change introduces new \Mail::IMAP\ and \Mail::POP3\ retriever classes that replace the previous singleton-based network implementation, allowing for multiple concurrent connections and different delivery methods per message instance. These retrievers provide \Mail.first\, \Mail.last\, \Mail.all\, and \Mail.find\ methods to retrieve emails, supporting options for ordering, counting, and searching. A key behavioral addition is the \:delete\_after\_find\ option and the \find\_and\_delete\ convenience method, which allow users to retrieve and automatically delete emails from the server. The IMAP retriever also adds support for STARTTLS, read-only sessions, and UTF-7 encoded mailbox names, while the POP3 retriever supports configurable read timeouts.

_lib/mail/network/retriever\methods · high confidence

Introduce structured and unstructured header field classes

The library now defines explicit field classes for all standard email headers (such as To, From, Date, Content-Type, and Message-ID) within lib/mail/fields. These classes replace the previous generic handling by providing dedicated parsing, encoding, and decoding logic for structured headers (like addresses and dates) and unstructured headers (like Subject and Comments). This change ensures that header values are correctly formatted according to RFC 2822 and MIME standards, handling edge cases like Bcc suppression, Content-Type sanitization, and multi-value message IDs.

lib/mail/fields · high confidence

Mail 2.9.0 release with breaking FIELDS\_MAP change and performance improvements

This release introduces a breaking change where Mail::Field::FIELDS\_MAP now contains class names instead of Class instances. It also includes performance optimizations by reducing object allocations through the use of Regexp\#match? and String\#unpack1, alongside bug fixes for charset preservation when adding parts and a regression where adding a part reset the mail's charset to nil. The release notes also highlight compatibility updates such as correct MIME-Version casing per RFC 2045, improved README documentation for multipart mail, and the addition of a delivery\_interceptors method to the Mail class.

(repo-wide) · high confidence

Mail header parsing engine replaced with Ragel

The internal mail parsing engine in lib/mail/parsers has been replaced from Treetop to Ragel, resulting in new .rl source files and generated .rb parsers for headers such as Address-List, Content-Disposition, Content-Location, Content-Transfer-Encoding, Content-Type, Date-Time, and Envelope-From. This change improves parsing performance and memory efficiency, and adds support for parsing UTF-8 mail headers per RFC 6532, handling a wider variety of non-RFC Message-ID formats, and correctly parsing addresses that begin with a comment.

lib/mail/parsers · high confidence

Multibyte string handling rewritten with Unicode 7.0 support

The multibyte string handling in Mail has been completely rewritten to remove the dependency on ActiveSupport and i18n, replacing it with a self-contained implementation that supports Unicode 7.0.0. This change introduces new \Mail::Multibyte::Chars\ and \Mail::Multibyte::Unicode\ modules to provide encoding-safe string operations (such as case conversion, slicing, and normalization) without altering the encoding of the original string argument. The update also drops support for Ruby versions under 2.5 and modernizes the codebase with frozen string literals and Ruby 2.3+ syntax.

lib/mail/multibyte · high confidence

Replaced Treetop parser with Ragel-based parsing for email elements

The mail library has switched its underlying parsing engine from Treetop to Ragel, resulting in new, dedicated element classes (such as Address, AddressList, ContentTypeElement, and ReceivedElement) that wrap the new parsers. This change improves performance and memory allocation while maintaining compatibility with existing APIs; users will see more robust handling of edge cases like invalid dates in Received headers and better support for group addresses, though the internal implementation details have changed significantly.

lib/mail/elements · high confidence

Rewritten encoding and transfer-encoding negotiation system

The mail library's encoding subsystem has been completely replaced with a new registration-based architecture that handles transfer-encoding negotiation more robustly. The new system introduces a hierarchy of encoding classes (Identity, 7bit, 8bit, Binary, Base64, Quoted-Printable, and Unix-to-Unix) that automatically negotiate the most efficient encoding based on content compatibility and cost. Key improvements include proper handling of line endings to prevent attachment corruption, support for binary content, and adherence to RFC standards for line length limits. The change also adds support for uuencode encoding and ensures that text content is properly normalized for Quoted-Printable encoding.

lib/mail/encodings · high confidence

Test coverage

Added comprehensive test coverage for mail header fields; Added comprehensive test coverage for mail parsing, encoding, and delivery configuration; Added custom RSpec matcher for validating object attribute breakdowns; Added specs for IMAP, POP3, and Test retriever methods; Added specs for address list and content-transfer-encoding parsers; Added test coverage for mail element parsers; Added test coverage for mail encoding modules; Added test coverage for network delivery methods; Added test fixtures for attachment parsing and error handling; Added test infrastructure and RSpec matchers for email assertions.

Dependencies

Initial gem specification and development environment setup

This change introduces the foundational \mail.gemspec\ and \Gemfile\ for the project. It defines the runtime dependencies required for email handling, specifically \logger\, \mini\_mime\ (\>= 0.1.1), and the standard library extensions \net-smtp\, \net-imap\, and \net-pop\. It also sets the minimum supported Ruby version to 2.5. For development, it establishes a test environment using RSpec 3.0, Bundler, and other tooling like RDoc and Rufo, while conditionally including \jruby-openssl\ for JRuby platforms and \byebug\ for MRI.

(dependencies) · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Score

  • CAI 64 → 62 (-1.9)
  • Rubric changed (rubric-2026.09.8 → rubric-2026.09.16) — scores are not directly comparable.

Lenses

  • Code Health 84 → 84 (+0.0)
  • Architecture 100 → 75 (-25.4)
  • Maturity 55 → 55 (+0.0)
  • Readiness 58 → 58 (+0.0)
  • Security 86 → 92 (+5.5)

Resolved (8)

  • Documentation: no installation or build instructions (README.md)
  • Documentation: no licence statement (README.md)
  • Documentation: no usage examples (README.md)
  • Low CVE: [GHSA redacted] (Gemfile)
  • Medium CVE: [GHSA redacted] (Gemfile)
  • Medium CVE: [GHSA redacted] (Gemfile)
  • Medium CVE: [GHSA redacted] (Gemfile)
  • Medium CVE: [GHSA redacted] (Gemfile)

New (5)

  • Ambiguous signatures for encoding/decoding. Body.encoded takes an optional transfer_encoding argument, while Body.decoded takes none. However, other types like ContentTypeField and MimeVersionField have encoded() and decoded() with no arguments. The presence of an argument in Body.encoded suggests it might force a specific encoding, whereas others might just return the current encoded form. This inconsistency in method signatures for similar operations across types is confusing.
  • Duplication of configuration logic between Mail class and Configuration class. Mail.delivery_method and Mail.retriever_method appear to be getters for global settings, while Configuration has both getters and setters (delivery_method(method, settings)). This creates two entry points for the same configuration state, risking inconsistency if one is updated and the other is read.
  • Inconsistent naming for retrieval operations. find typically implies raising an error if not found, while first/last/all are standard collection queries. find_and_delete is a destructive operation mixed with retrieval. The use of args and block for all these suggests a generic query interface, but the naming convention mixes SQL-like (find) with Enumerable-like (first, all) and destructive (find_and_delete) verbs without a clear hierarchy or distinction in the API surface.
  • Projects may be oversized for their cohesion
  • Redundant and inconsistent delivery entry points. Mail.deliver is a class-level convenience method that likely creates a new Message instance and delivers it. Message.deliver and Message.deliver! are instance methods. The existence of Mail.deliver alongside instance methods creates confusion about whether to use the class facade or instantiate a Message first. Furthermore, deliver vs deliver! implies a difference in error handling (e.g., raising exceptions), but this distinction is not mirrored in the class-level Mail.deliver.

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

mikel/mail was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 28 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit d645d7b5b7d03218b0bc8971ef041c991a63f5f7 — the exact code this score is about.
  • Scored under rubric-2026.09.16 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-2d9048c36d26.