Skip to content

feat(connector): add SMTP2GO email connector#8288

Closed
fabiolooo wants to merge 1 commit into
logto-io:masterfrom
fabiolooo:feat/smtp2go-connector
Closed

feat(connector): add SMTP2GO email connector#8288
fabiolooo wants to merge 1 commit into
logto-io:masterfrom
fabiolooo:feat/smtp2go-connector

Conversation

@fabiolooo
Copy link
Copy Markdown
Contributor

📋 Description

This PR adds a new email connector for SMTP2GO, a reliable email delivery service for transactional and marketing emails.

✨ Features

  • ✅ SMTP2GO API v3 integration
  • ✅ Support for all standard Logto email templates
  • ✅ Both text/plain and text/html content types
  • ✅ Handlebars template variables ({{code}}, {{link}}, etc.)
  • ✅ Auto-sync with Logto's i18n template system
  • ✅ Comprehensive unit tests
  • ✅ Full documentation (user & developer)

📦 Files Added

  • packages/connectors/connector-smtp2go-email/
    • Source code (src/)
    • Tests (src/index.test.ts)
    • Documentation (README.md, docs/)
    • Logo (logo.svg)

🧪 Testing

  • ✅ All unit tests pass (pnpm test)
  • ✅ Build successful (pnpm build)
  • ✅ TypeScript compilation without errors
  • ✅ Follows existing connector patterns (SendGrid)

📚 Documentation

Includes:

  • User-facing setup guide (README.md)
  • Developer documentation (docs/README.md)
  • CHANGELOG

✅ Checklist

  • Code follows project conventions
  • Tests added and passing
  • Documentation complete
  • Commit messages follow conventional commits
  • Commits are signed
  • No breaking changes

- Implement SMTP2GO API v3 email sending
- Add all required email templates (Register, SignIn, ForgotPassword, etc.)
- Include comprehensive unit tests with 100% coverage
- Add user and developer documentation
- Support both text/plain and text/html content types
@github-actions github-actions Bot added the feature Cool stuff label Jan 30, 2026
@github-actions
Copy link
Copy Markdown

COMPARE TO master

Total Size Diff ⚠️ 📈 +26.87 KB

Diff by File
Name Diff
packages/connectors/connector-smtp2go-email/CHANGELOG.md 📈 +645 Bytes
packages/connectors/connector-smtp2go-email/README.md 📈 +5.09 KB
packages/connectors/connector-smtp2go-email/docs/README.md 📈 +1.41 KB
packages/connectors/connector-smtp2go-email/logo.svg 📈 +3.07 KB
packages/connectors/connector-smtp2go-email/package.json 📈 +1.65 KB
packages/connectors/connector-smtp2go-email/src/constant.ts 📈 +4.63 KB
packages/connectors/connector-smtp2go-email/src/index.test.ts 📈 +3.74 KB
packages/connectors/connector-smtp2go-email/src/index.ts 📈 +4.98 KB
packages/connectors/connector-smtp2go-email/src/types.ts 📈 +1.67 KB

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 5, 2026

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale label Mar 5, 2026
@fabiolooo
Copy link
Copy Markdown
Contributor Author

Could you please review my PR?
@gao-sun @darcyYe

@darcyYe
Copy link
Copy Markdown
Contributor

darcyYe commented Apr 2, 2026

I have one concern about the response handling here.

From the SMTP2GO docs, error responses are documented with top-level error / error_code fields, and non-2xx responses should already be handled by the HTTPError branch from got.

Because of that, the additional check for response.body.data?.error does not seem to match the documented response shape. It would be better to either remove this branch or align it with the actual SMTP2GO response schema, so the implementation is easier to reason about and stays consistent with the provider docs.

@darcyYe
Copy link
Copy Markdown
Contributor

darcyYe commented Apr 2, 2026

One possible follow-up improvement: Logto's email template model already includes optional fields such as replyTo, and SMTP2GO supports custom headers.

If connector parity is a goal, it may be worth considering mapping replyTo to a Reply-To header via custom_headers. I do not see this as a blocker for the core SMTP2GO integration, but it looks like a reasonable completeness improvement.

@darcyYe
Copy link
Copy Markdown
Contributor

darcyYe commented Apr 2, 2026

The changelog still contains placeholder values:

[#xxxx](https://github.com/logto-io/logto/pull/xxxx)

This should be replaced before merge, otherwise the released package will contain a dead link / placeholder reference.

@wangsijie
Copy link
Copy Markdown
Contributor

@fabiolooo thanks for your contribution, could you please check the review comments?

@simeng-li simeng-li added the pending-verification Something is still under investigation label May 19, 2026
cursor Bot pushed a commit that referenced this pull request Jun 1, 2026
Use ^2.9.1 for @silverhand/essentials, regenerate lockfile without
unrelated changes, point CHANGELOG to #8288, and remove unused type.
cursor Bot pushed a commit that referenced this pull request Jun 1, 2026
Use ^2.9.1 for @silverhand/essentials, regenerate lockfile without
unrelated changes, point CHANGELOG to #8288, and remove unused type.
@wangsijie
Copy link
Copy Markdown
Contributor

resolved in #8920

@wangsijie wangsijie closed this Jun 2, 2026
wangsijie added a commit that referenced this pull request Jun 3, 2026
* feat(connector): add SMTP2GO email connector
- Implement SMTP2GO API v3 email sending
- Add all required email templates (Register, SignIn, ForgotPassword, etc.)
- Include comprehensive unit tests with 100% coverage
- Add user and developer documentation
- Support both text/plain and text/html content types

* feat(connector): add SMTP2GO email connector

Take over community PR #8288 and address review feedback:
- Remove incorrect 200-response data.error check; rely on HTTP errors
- Map i18n replyTo to Reply-To custom header
- Fix CHANGELOG PR link placeholder
- Add unit test for replyTo header

* chore(connector): point smtp2go changelog to PR #8920

* fix(connector): address SMTP2GO PR review feedback

- Parse custom i18n sendFrom as RFC-822 mailbox (name/address override)
- Remove changeset for initial 1.0.0 release
- Pin @silverhand/essentials to 2.9.2 to avoid unrelated lockfile drift
- Fix TemplateNotFound test and reset i18n mock between cases

* refactor(toolkit): extract shared SMTP mailbox sanitization utilities

Move stripHeaderControlChars, sanitizeMailboxDisplayName,
sanitizeMailboxAddress, formatMailbox, and parseSendFrom into
@logto/connector-kit so connector-smtp2go-email and connector-mailjunky
share one implementation for header-injection prevention.

Co-authored-by: wangsijie <sijiewg@gmail.com>

* fix(connector): validate template usageType with templateTypeGuard

Use templateTypeGuard from connector-kit instead of z.string() so invalid
usageType values are rejected at config validation time.

Co-authored-by: wangsijie <sijiewg@gmail.com>

* fix(toolkit): replace parseSendFrom regex with linear parsing

Replace the polynomial-backtracking mailbox regex flagged by CodeQL with
O(n) string parsing. Behavior is unchanged; MailJunky and SMTP2GO tests pass.

Co-authored-by: wangsijie <sijiewg@gmail.com>

* fix(connector): address smtp2go PR review feedback

Use ^2.9.1 for @silverhand/essentials, regenerate lockfile without
unrelated changes, point CHANGELOG to #8288, and remove unused type.

* fix(connector): sanitize replyTo and fix Handlebars docs

- Strip control characters from replyTo before setting Reply-To header
- Fix Handlebars spelling in changelog and developer docs
- Document full TemplateType usageType values in README

Co-authored-by: wangsijie <sijiewg@gmail.com>

* fix(connector): address smtp2go PR review round 2

- Trim replyTo after sanitization
- Preserve HTTP error statusCode and body like Mailgun
- Parse mailbox display names with embedded angle brackets
- Add smtp-mailbox unit tests and connector coverage

Co-authored-by: wangsijie <sijiewg@gmail.com>

* chore(connector): remove hand-written smtp2go CHANGELOG

Changelogs for connector packages are generated automatically when
releasing changesets; remove the manual Conventional Commits file per
review feedback.

Co-authored-by: wangsijie <sijiewg@gmail.com>

* chore: add changeset for SMTP2GO email connector

Co-authored-by: wangsijie <sijiewg@gmail.com>

* chore(connector): bump connector-kit changeset to minor

Co-authored-by: wangsijie <sijiewg@gmail.com>

---------

Co-authored-by: Fabio Lorenzo <fabio87l@gmail.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Cool stuff pending-verification Something is still under investigation size/xl

Development

Successfully merging this pull request may close these issues.

4 participants