Skip to content

Conversation

@ElijahAhianyo
Copy link
Contributor

This is a continuation of #250

trkelly23 and others added 27 commits March 15, 2025 14:12
Initial commit of email.rs using lettre
Initial commit of Add email support using lettre crate
Added the message printout if debug mode is enabled
Added a test and deferred the extra headers and attachment features.
Added tests for config and send_email(ignore).
@github-actions github-actions bot added the C-lib Crate: cot (main library crate) label Dec 1, 2025
[resolver]
incompatible-rust-versions = "fallback"

[target.x86_64-pc-windows-msvc]
Copy link
Contributor Author

@ElijahAhianyo ElijahAhianyo Dec 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default linker on windows fails when compiling with chumsky crate which is used by lettre. A workaround is to use the llvm linker and set the symbol mangling version to v0. Also need to use [target.x86_64-pc-windows-msvc] specifically as [target.'cfg(target_os = "windows")'] fails in the CI

rust-lang/rust#141626

zesterer/chumsky#815

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, this is definitely a sort of error I totally wouldn't expect! Can we add a # TODO comment to remove this part of the config when the upstream bug is fixed? The links to the bug reports should be included in TODO.

This is sort of unfortunate, though, as it will most likely prevent Cot from being built on Windows with the email feature enabled, unless users add similar config to their project (I see you added the config to the default project template - good!). Hopefully this gets resolved soon!

type Error = EmailMessageError;

fn try_from(message: EmailMessage) -> Result<Self, Self::Error> {
let from_mailbox = message
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would have loved to add a server_email in the config to use here as a default if not specified for convenience, but there's no nice way to do that

@ElijahAhianyo ElijahAhianyo changed the title wip!: feat!: Email support using lettre feat!: Email support using lettre Dec 21, 2025
@ElijahAhianyo ElijahAhianyo requested review from m4tx and seqre December 21, 2025 05:25
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds comprehensive email support to the Cot framework using the lettre library, providing both console (development) and SMTP (production) transport backends for sending emails.

Key Changes:

  • Implements high-level Email API with EmailMessage builder pattern for constructing and sending emails
  • Adds console and SMTP transport backends with pluggable architecture via Transport trait
  • Integrates email service into the request context and project configuration system

Reviewed changes

Copilot reviewed 26 out of 27 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
examples/send-email/ Complete example application demonstrating email functionality with HTML form and status feedback
cot/src/email/ Core email module with message building, transport abstraction, and backend implementations
cot/src/config.rs Email configuration structures supporting console and SMTP transports with URL-based config
cot/src/request.rs Request extension trait additions to access email service
cot/src/project.rs Email service initialization and integration into project bootstrap lifecycle
cot/Cargo.toml New email feature flag and lettre dependency
deny.toml Apache-2.0 WITH LLVM-exception license allowance for new dependencies
cot-cli/src/project_template/ Default email configuration in project templates
.github/workflows/rust.yml CI toolchain version updates
.cargo/config.toml Windows linker configuration for faster builds

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@m4tx m4tx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a really nice piece of work! I'll need to have another look at the actual email logic in the PR, but this overall looks decent. Please make sure to have a look at the Copilot review as well - it has found a few nitpicks.

[resolver]
incompatible-rust-versions = "fallback"

[target.x86_64-pc-windows-msvc]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, this is definitely a sort of error I totally wouldn't expect! Can we add a # TODO comment to remove this part of the config when the upstream bug is fixed? The links to the bug reports should be included in TODO.

This is sort of unfortunate, though, as it will most likely prevent Cot from being built on Windows with the email feature enabled, unless users add similar config to their project (I see you added the config to the default project template - good!). Hopefully this gets resolved soon!

m4tx added a commit that referenced this pull request Dec 24, 2025
This makes the API more ergonomic, as `Arc` should really just be an
implementation detail, rather than something exposed to the user.

This is a followup to the discussion here:
#419 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ci Area: CI (Continuous Integration) C-cli Crate: cot-cli (issues and Pull Requests related to Cot CLI) C-lib Crate: cot (main library crate)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants