Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(utils/smtp): Refactor SMTP pool using gomail.v2 to resolve STARTTLS compatibility issues #269

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Ogannesson
Copy link

fix(utils/smtp): Refactor SMTP pool using gomail.v2 to resolve STARTTLS compatibility issues

  • Refactor SMTP connection pool implementation
  • Optimize pool resource management

原先的实现会在使用部分SMTP提供商的服务时出现auth failed: SMTP error 504: AUTH LOGIN not supported,因此我使用了更现代的gomail.v2改进了发件部分。
代码已分别在一家使用TLS的服务商(ahasend)和一家使用SSL的服务商(阿里云)上通过测试。

…LS compatibility issues

- Refactor SMTP connection pool implementation
- Optimize pool resource management
@zijiren233 zijiren233 self-requested a review December 16, 2024 02:57
utils/smtp/smtpool.go Outdated Show resolved Hide resolved
Remove SMTP connection pool in favor of direct connections

BREAKING CHANGE: Replace SMTP connection pool with direct connections

The SMTP connection pool has been removed in favor of creating new
connections for each email send operation. This change:

- Removes Pool struct and related code
- Adds new Mailer struct for handling email operations
- Updates all email sending functions to use new Mailer
- Removes pool size configuration
- Simplifies connection management

Rationale:
- SMTP servers often don't handle long-lived connections well
- Connection pool adds complexity without significant benefits
- Direct connections are more reliable for email sending
- Email sending is typically not high-frequency enough to warrant pooling

Migration:
- Replace getSmtpPool() calls with getMailer()
- Update any direct Pool usage to use Mailer instead
@Ogannesson Ogannesson reopened this Dec 29, 2024
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.

2 participants