[GH-ISSUE #1446] Support Gmail Relay via Nodemailer: Add an SMTP Service Option #407

Closed
opened 2026-02-26 18:46:55 +03:00 by kerem · 2 comments
Owner

Originally created by @Jorgagu on GitHub (Nov 5, 2024).
Original GitHub issue: https://github.com/documenso/documenso/issues/1446

Originally assigned to: @Jorgagu on GitHub.

Describe the improvement you are suggesting in detail

Issue Title:

Support Gmail Relay via Nodemailer: Add an SMTP Service Option

Description:

When configuring email sending using Gmail Relay with Nodemailer, the current setup fails to send emails properly. This issue appears to be due to the missing service: "gmail" option in the Nodemailer configuration.

Steps to Reproduce:

  1. Configure the Documenso project with an SMTP server using Gmail Relay.
NEXT_PRIVATE_SMTP_HOST="smtp-relay.gmail.com"
NEXT_PRIVATE_SMTP_PORT=587
NEXT_PRIVATE_SMTP_SECURE=true
  1. Attempt to send an email using the current configuration settings (without specifying an SMTP service).
  2. Observe that the email sending fails.

Logs:

@documenso/web:dev: [JOBS]: Triggering job send.signup.confirmation.email with payload { email: '***@***' } 
@documenso/web:dev: [JOBS]: Job send.signup.confirmation.email failed Error: Failed to send the confirmation email
@documenso/web:dev:     at sendConfirmationToken (webpack-internal:///(api)/../../packages/lib/server-only/user/send-confirmation-token.ts:65:15)
@documenso/web:dev:     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
@documenso/web:dev:     at async Object.handler (webpack-internal:///(api)/../../packages/lib/jobs/definitions/emails/send-confirmation-email.ts:26:9)
@documenso/web:dev:     at async eval (webpack-internal:///(api)/../../packages/lib/jobs/client/local.ts:131:17)
@documenso/web:dev:     at async K (node_modules/next/dist/compiled/next-server/pages-api.runtime.dev.js:21:2871)
@documenso/web:dev:     at async U.render (node_modules/next/dist/compiled/next-server/pages-api.runtime.dev.js:21:3955)
@documenso/web:dev:     at async DevServer.runApi (node_modules/next/dist/server/next-server.js:600:9)
@documenso/web:dev:     at async NextNodeServer.handleCatchallRenderRequest (node_modules/next/dist/server/next-server.js:269:37)
@documenso/web:dev:     at async DevServer.handleRequestImpl (node_modules/next/dist/server/base-server.js:816:17)
@documenso/web:dev:     at async node_modules/next/dist/server/dev/next-dev-server.js:339:20
@documenso/web:dev:     at async Span.traceAsyncFn (node_modules/next/dist/trace/trace.js:154:20)
@documenso/web:dev:     at async DevServer.handleRequest (node_modules/next/dist/server/dev/next-dev-server.js:336:24)
@documenso/web:dev:     at async invokeRender (node_modules/next/dist/server/lib/router-server.js:174:21)
@documenso/web:dev:     at async handleRequest (node_modules/next/dist/server/lib/router-server.js:353:24)
@documenso/web:dev:     at async requestHandlerImpl (node_modules/next/dist/server/lib/router-server.js:377:13)
@documenso/web:dev: Submitting job to endpoint: http://localhost:3000/api/jobs/send.signup.confirmation.email/cm34bfr4l0000m2esgma62e46

Proposed Solution:

  • Introduce a new optional environment variable, NEXT_PRIVATE_SMTP_SERVICE, to specify the service for Nodemailer.
  • Update the mailer.ts file to conditionally include this option:
return createTransport({
    host: process.env.NEXT_PRIVATE_SMTP_HOST ?? 'localhost:2500',
    port: Number(process.env.NEXT_PRIVATE_SMTP_PORT) || 587,
    secure: process.env.NEXT_PRIVATE_SMTP_SECURE === 'true',
    ignoreTLS: process.env.NEXT_PRIVATE_SMTP_UNSAFE_IGNORE_TLS === 'true',
    auth: process.env.NEXT_PRIVATE_SMTP_USERNAME
      ? {
          user: process.env.NEXT_PRIVATE_SMTP_USERNAME,
          pass: process.env.NEXT_PRIVATE_SMTP_PASSWORD ?? '',
        }
      : undefined,
    ...(process.env.NEXT_PRIVATE_SMTP_SERVICE ? { service: process.env.NEXT_PRIVATE_SMTP_SERVICE } : {}),
});

Impact:

  • This change ensures compatibility with Gmail Relay while preserving the existing functionality for other SMTP configurations.

Configuration Example:

# OPTIONAL: Defines the service for nodemailer
NEXT_PRIVATE_SMTP_SERVICE=

Additional Notes:

This solution does not alter the default configuration and introduces no breaking changes, ensuring backward compatibility.

Additional Information & Alternatives (optional)

No response

Do you want to work on this improvement?

Yes

Please check the boxes that apply to this improvement suggestion.

  • I have searched the existing issues and improvement suggestions to avoid duplication.
  • I have provided a clear description of the improvement being suggested.
  • I have explained the rationale behind this improvement.
  • I have included any relevant technical details or design suggestions.
  • I understand that this is a suggestion and that there is no guarantee of implementation.
Originally created by @Jorgagu on GitHub (Nov 5, 2024). Original GitHub issue: https://github.com/documenso/documenso/issues/1446 Originally assigned to: @Jorgagu on GitHub. ### Describe the improvement you are suggesting in detail ### Issue Title: Support Gmail Relay via Nodemailer: Add an SMTP Service Option ### Description: When configuring email sending using Gmail Relay with Nodemailer, the current setup fails to send emails properly. This issue appears to be due to the missing `service: "gmail"` option in the Nodemailer configuration. ### Steps to Reproduce: 1. Configure the Documenso project with an SMTP server using Gmail Relay. ```env NEXT_PRIVATE_SMTP_HOST="smtp-relay.gmail.com" NEXT_PRIVATE_SMTP_PORT=587 NEXT_PRIVATE_SMTP_SECURE=true ``` 3. Attempt to send an email using the current configuration settings (without specifying an SMTP service). 4. Observe that the email sending fails. ### Logs: ```bash @documenso/web:dev: [JOBS]: Triggering job send.signup.confirmation.email with payload { email: '***@***' } @documenso/web:dev: [JOBS]: Job send.signup.confirmation.email failed Error: Failed to send the confirmation email @documenso/web:dev: at sendConfirmationToken (webpack-internal:///(api)/../../packages/lib/server-only/user/send-confirmation-token.ts:65:15) @documenso/web:dev: at process.processTicksAndRejections (node:internal/process/task_queues:95:5) @documenso/web:dev: at async Object.handler (webpack-internal:///(api)/../../packages/lib/jobs/definitions/emails/send-confirmation-email.ts:26:9) @documenso/web:dev: at async eval (webpack-internal:///(api)/../../packages/lib/jobs/client/local.ts:131:17) @documenso/web:dev: at async K (node_modules/next/dist/compiled/next-server/pages-api.runtime.dev.js:21:2871) @documenso/web:dev: at async U.render (node_modules/next/dist/compiled/next-server/pages-api.runtime.dev.js:21:3955) @documenso/web:dev: at async DevServer.runApi (node_modules/next/dist/server/next-server.js:600:9) @documenso/web:dev: at async NextNodeServer.handleCatchallRenderRequest (node_modules/next/dist/server/next-server.js:269:37) @documenso/web:dev: at async DevServer.handleRequestImpl (node_modules/next/dist/server/base-server.js:816:17) @documenso/web:dev: at async node_modules/next/dist/server/dev/next-dev-server.js:339:20 @documenso/web:dev: at async Span.traceAsyncFn (node_modules/next/dist/trace/trace.js:154:20) @documenso/web:dev: at async DevServer.handleRequest (node_modules/next/dist/server/dev/next-dev-server.js:336:24) @documenso/web:dev: at async invokeRender (node_modules/next/dist/server/lib/router-server.js:174:21) @documenso/web:dev: at async handleRequest (node_modules/next/dist/server/lib/router-server.js:353:24) @documenso/web:dev: at async requestHandlerImpl (node_modules/next/dist/server/lib/router-server.js:377:13) @documenso/web:dev: Submitting job to endpoint: http://localhost:3000/api/jobs/send.signup.confirmation.email/cm34bfr4l0000m2esgma62e46 ``` ### Proposed Solution: - Introduce a new optional environment variable, `NEXT_PRIVATE_SMTP_SERVICE`, to specify the service for Nodemailer. - Update the `mailer.ts` file to conditionally include this option: ```javascript return createTransport({ host: process.env.NEXT_PRIVATE_SMTP_HOST ?? 'localhost:2500', port: Number(process.env.NEXT_PRIVATE_SMTP_PORT) || 587, secure: process.env.NEXT_PRIVATE_SMTP_SECURE === 'true', ignoreTLS: process.env.NEXT_PRIVATE_SMTP_UNSAFE_IGNORE_TLS === 'true', auth: process.env.NEXT_PRIVATE_SMTP_USERNAME ? { user: process.env.NEXT_PRIVATE_SMTP_USERNAME, pass: process.env.NEXT_PRIVATE_SMTP_PASSWORD ?? '', } : undefined, ...(process.env.NEXT_PRIVATE_SMTP_SERVICE ? { service: process.env.NEXT_PRIVATE_SMTP_SERVICE } : {}), }); ``` ### Impact: - This change ensures compatibility with Gmail Relay while preserving the existing functionality for other SMTP configurations. ### Configuration Example: ```env # OPTIONAL: Defines the service for nodemailer NEXT_PRIVATE_SMTP_SERVICE= ``` ### Additional Notes: This solution does not alter the default configuration and introduces no breaking changes, ensuring backward compatibility. ### Additional Information & Alternatives (optional) _No response_ ### Do you want to work on this improvement? Yes ### Please check the boxes that apply to this improvement suggestion. - [X] I have searched the existing issues and improvement suggestions to avoid duplication. - [X] I have provided a clear description of the improvement being suggested. - [X] I have explained the rationale behind this improvement. - [X] I have included any relevant technical details or design suggestions. - [X] I understand that this is a suggestion and that there is no guarantee of implementation.
kerem 2026-02-26 18:46:55 +03:00
Author
Owner

@github-actions[bot] commented on GitHub (Nov 5, 2024):

Thank you for opening your first issue and for being a part of the open signing revolution!

One of our team members will review it and get back to you as soon as it possible 💚

Meanwhile, please feel free to hop into our community in Discord

<!-- gh-comment-id:2456931012 --> @github-actions[bot] commented on GitHub (Nov 5, 2024): Thank you for opening your first issue and for being a part of the open signing revolution! <br /> One of our team members will review it and get back to you as soon as it possible 💚 <br /> Meanwhile, please feel free to hop into our community in [Discord](https://documen.so/discord)
Author
Owner

@dguyen commented on GitHub (Nov 5, 2024):

Sounds good! Assigned it to you

<!-- gh-comment-id:2456993123 --> @dguyen commented on GitHub (Nov 5, 2024): Sounds good! Assigned it to you
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/documenso#407
No description provided.