Skip to content

Use custom smtp relay for email transport#2077

Open
Calanas wants to merge 7 commits intotrycompai:mainfrom
Calanas:feature/smtp-relay
Open

Use custom smtp relay for email transport#2077
Calanas wants to merge 7 commits intotrycompai:mainfrom
Calanas:feature/smtp-relay

Conversation

@Calanas
Copy link
Contributor

@Calanas Calanas commented Jan 30, 2026

What does this PR do?

Alternatively, it is now possible to use a custom (SMTP) mail server for email transport. The goal is to connect this application to an already existing infrastructure and to reduce the number of external (meaning outside the company boundaries) dependencies.

Resend will still be the default. But for companies who cannot use online services that easily, the SMTP relay might be a proper alternative.

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

Prerequisites

Remove / comment the RESEND_API_KEY from your environment since it would be taken as the default otherwise.

Steps to reproduce

Configure a custom SMTP relay with those environment variables (use your own SMTP server):

RELAY_SMTP_HOST="smtp-relay.example.com"
RELAY_SMTP_PORT="587"
RELAY_SMTP_USER="username"
RELAY_SMTP_PASS="password"

Start the application and use the continue with email option:
image

In the app logs, you will recognize an information text
[next] Using SMTP-Relay as mail service.

as well as the correct mail service provider

[next] [email] send start {
[next]   requestId: '8384622c-7921-4924-9e2a-2cbc5b09d9bd',
[next]   provider: 'relay',
[next]   from: '***',
[next]   to: '***',
[next]   subject: 'Login to Comp AI',
[next]   scheduledAt: undefined,
[next]   flags: { marketing: false, system: false, test: false }
[next] }

And of course, the mail will be delivered.

Signed-off-by: Andreas Reußner <andreas.reussner@rgigroup.com>
Signed-off-by: Andreas Reußner <andreas.reussner@rgigroup.com>
Signed-off-by: Andreas Reussner <andreas.reussner@rgigroup.com>
Signed-off-by: Andreas Reußner <andreas.reussner@rgigroup.com>
@vercel
Copy link

vercel bot commented Jan 30, 2026

@Calanas is attempting to deploy a commit to the Comp AI Team on Vercel.

A member of the Team first needs to authorize it.

Signed-off-by: Andreas Reussner <andreas.reussner@rgigroup.com>
@Calanas Calanas marked this pull request as ready for review January 30, 2026 14:17
@cursor
Copy link

cursor bot commented Jan 30, 2026

PR Summary

Medium Risk
Email delivery is core user functionality; introducing a new SMTP transport and changing env validation can cause production send failures if configuration is incomplete or differs from Resend behavior (e.g., scheduling).

Overview
Adds a pluggable mail transport in @trycompai/email that chooses Resend by default or falls back to a custom SMTP relay (RELAY_SMTP_*) via nodemailer, rendering React emails to HTML for SMTP and warning that scheduledAt is not supported.

Updates API/app/portal email senders to use getMailService().send(...) and logs the active provider, relaxes RESEND_API_KEY to optional, introduces relay env vars in env.mjs, and documents the new SMTP relay option in the self-hosting env reference.

Written by Cursor Bugbot for commit 54c651c. This will update automatically on new commits. Configure here.

Signed-off-by: Andreas Reußner <andreas.reussner@outlook.de>
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

- add warning for mail scheduling
- add runtime environment variables

Signed-off-by: Andreas Reußner <andreas.reussner@outlook.de>
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