Skip to content

Inline mail/internal/mail package into mail package#2423

Merged
paganotoni merged 1 commit intomodernize-go-featuresfrom
inline-mail-internal-package
Mar 20, 2026
Merged

Inline mail/internal/mail package into mail package#2423
paganotoni merged 1 commit intomodernize-go-featuresfrom
inline-mail-internal-package

Conversation

@paganotoni
Copy link
Member

Summary

This PR eliminates the package indirection by moving the SMTP implementation code directly into the main package. This simplifies the codebase and makes the mail package easier to understand and maintain.

Changes

  • Moved all code from to files
  • Removed the directory entirely
  • Renamed internal types to avoid conflicts ( -> , etc.)
  • Unexported internal implementation details that don't need to be public
  • Added proper attribution to the go-mail/mail project (MIT License)
  • Added documentation comments to all exported types and functions
  • Added TODOs for future improvements from the original go-mail README

Rationale

The original package was a vendored copy of the go-mail/mail library. While this provided a well-tested SMTP implementation, it added unnecessary package indirection. By inlining the code:

  1. Simpler dependency graph - One less package to understand
  2. Easier maintenance - All mail-related code is now in one place
  3. Clearer attribution - The code still properly credits go-mail/mail
  4. Same functionality - The public API remains unchanged

Public API

No breaking changes. Users can still configure to customize SMTP settings like SSL, TLSConfig, StartTLSPolicy, Timeout, etc.

TODOs for Future Work

Based on the original go-mail/mail README, these improvements are still pending:

  • Properly encode filenames for non-ASCII characters
  • Properly encode email addresses for non-ASCII characters
  • Test embedded files and attachments for their existence before sending
  • Allow supplying an when embedding and attaching files

This change eliminates the internal/mail package indirection by moving the
SMTP implementation code directly into the main mail package. This simplifies
the codebase and makes the mail package easier to understand and maintain.

Changes made:
- Moved all code from mail/internal/mail/* to mail/smtp_*.go files
- Removed the mail/internal/ directory entirely
- Renamed internal types to avoid conflicts (Message -> smtpMessage, etc.)
- Unexported internal implementation details that don't need to be public
- Added proper attribution to the go-mail/mail project (MIT License)
- Added documentation comments to all exported types and functions
- Added TODOs for future improvements from the original go-mail README:
  - Proper encoding of filenames for non-ASCII characters
  - Proper encoding of email addresses for non-ASCII characters
  - Testing embedded files and attachments for existence
  - Allowing io.Reader when embedding and attaching files

The public API remains unchanged. Users can still configure
to customize SMTP settings like SSL, TLSConfig, StartTLSPolicy, etc.

The original go-mail/mail package provided a well-tested SMTP implementation
that Buffalo has used internally. By inlining it with proper attribution,
we maintain that functionality while reducing package complexity.
@paganotoni paganotoni requested a review from a team as a code owner March 20, 2026 22:23
@paganotoni paganotoni merged commit 059092f into modernize-go-features Mar 20, 2026
8 checks passed
@paganotoni paganotoni deleted the inline-mail-internal-package branch March 20, 2026 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant