[PR #1897] [CLOSED] Mailer Module Cleanup and improvement #16108

Closed
opened 2025-11-02 12:02:29 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-gitea/gitea/pull/1897
Author: @r0l1
Created: 6/7/2017
Status: Closed

Base: masterHead: master


📝 Commits (10+)

  • fce37d3 Cleaned up the mailer module. Added support for multiple
  • a92d57e Merge branch 'master' into master
  • 86a6f71 added gitea authors comments.
  • 0416b37 included last master commit #1648
  • cb6d379 Merge branch 'master' of github.com:m4ng0squ4sh/gitea
  • 9426a69 rewrite and further cleanup.
  • ff07bc6 added some comments to the sendmail send function.
  • 4d02c7e added SendSync method.
  • 837f911 adjusted SendTestMail to use the new mailer implementation.
  • 7a304bc added new workers mail setting.

📊 Changes

13 files changed (+960 additions, -258 deletions)

View changed files

📝 models/mail.go (+7 -2)
modules/mailer/daemon.go (+132 -0)
📝 modules/mailer/mailer.go (+27 -256)
modules/mailer/message.go (+54 -0)
modules/mailer/sender.go (+25 -0)
modules/mailer/sendmail.go (+70 -0)
modules/mailer/smtp.go (+113 -0)
📝 modules/setting/setting.go (+2 -0)
vendor/github.com/desertbit/timer/LICENSE (+21 -0)
vendor/github.com/desertbit/timer/README.md (+154 -0)
vendor/github.com/desertbit/timer/timer.go (+118 -0)
vendor/github.com/desertbit/timer/timers.go (+231 -0)
📝 vendor/vendor.json (+6 -0)

📄 Description

I have some problems sending e-mails with gitea and had a look at the mailer code.
I noticed following points:

  • The code should be split up into multiple files to improve readability.
  • For each send mail request a new connection is established (no keep-alive).
  • The SMTP mail handling code is an old duplicate from gomail. Use the well-tested gomail implementation instead.
  • No support for multiple parallel mail routines.
  • SendAsync starts a new goroutine on every call. We should think about increasing the channel size and drop mail requests if flooded with requests... This requires discussion.
  • Sendmail code has to be cleaned up (Error handling).

This initial commit is a work in progress to improve the mailer code. Currently done:

  • SMTP keep-alive
  • Using gomail for SMTP handling
  • Multiple parallel mail routines
  • Initial cleanup and split up into multiple files.
  • Added several TODOs.
  • Sendmail code has been adjusted.

Any thoughts or ideas? Thanks!


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/go-gitea/gitea/pull/1897 **Author:** [@r0l1](https://github.com/r0l1) **Created:** 6/7/2017 **Status:** ❌ Closed **Base:** `master` ← **Head:** `master` --- ### 📝 Commits (10+) - [`fce37d3`](https://github.com/go-gitea/gitea/commit/fce37d307421aa5b4899e254038746f55bb415af) Cleaned up the mailer module. Added support for multiple - [`a92d57e`](https://github.com/go-gitea/gitea/commit/a92d57eb139d1361541f283ad76444102cb2be39) Merge branch 'master' into master - [`86a6f71`](https://github.com/go-gitea/gitea/commit/86a6f71ac7830eead37ccf9791783f716832d8d9) added gitea authors comments. - [`0416b37`](https://github.com/go-gitea/gitea/commit/0416b37758fb77b76daa5200b06354fae7663d6e) included last master commit #1648 - [`cb6d379`](https://github.com/go-gitea/gitea/commit/cb6d3797d7ec1e5c6c5fd44233e611fa8831c3fd) Merge branch 'master' of github.com:m4ng0squ4sh/gitea - [`9426a69`](https://github.com/go-gitea/gitea/commit/9426a69c21d459c0cdf9cf3f9056a86a37393925) rewrite and further cleanup. - [`ff07bc6`](https://github.com/go-gitea/gitea/commit/ff07bc65491d12f091960e02a7a1456b4ab2dba4) added some comments to the sendmail send function. - [`4d02c7e`](https://github.com/go-gitea/gitea/commit/4d02c7e6b8cdd74399581c0f825bc8ed53178e27) added SendSync method. - [`837f911`](https://github.com/go-gitea/gitea/commit/837f911d8bb0f696563701c31af16f4535bee8e6) adjusted SendTestMail to use the new mailer implementation. - [`7a304bc`](https://github.com/go-gitea/gitea/commit/7a304bc40c41b8a60f7463180315e7d673f4c380) added new workers mail setting. ### 📊 Changes **13 files changed** (+960 additions, -258 deletions) <details> <summary>View changed files</summary> 📝 `models/mail.go` (+7 -2) ➕ `modules/mailer/daemon.go` (+132 -0) 📝 `modules/mailer/mailer.go` (+27 -256) ➕ `modules/mailer/message.go` (+54 -0) ➕ `modules/mailer/sender.go` (+25 -0) ➕ `modules/mailer/sendmail.go` (+70 -0) ➕ `modules/mailer/smtp.go` (+113 -0) 📝 `modules/setting/setting.go` (+2 -0) ➕ `vendor/github.com/desertbit/timer/LICENSE` (+21 -0) ➕ `vendor/github.com/desertbit/timer/README.md` (+154 -0) ➕ `vendor/github.com/desertbit/timer/timer.go` (+118 -0) ➕ `vendor/github.com/desertbit/timer/timers.go` (+231 -0) 📝 `vendor/vendor.json` (+6 -0) </details> ### 📄 Description I have some problems sending e-mails with gitea and had a look at the mailer code. I noticed following points: - The code should be split up into multiple files to improve readability. - For each send mail request a new connection is established (no keep-alive). - The SMTP mail handling code is an old duplicate from gomail. Use the well-tested gomail implementation instead. - No support for multiple parallel mail routines. - SendAsync starts a new goroutine on every call. We should think about increasing the channel size and drop mail requests if flooded with requests... This requires discussion. - Sendmail code has to be cleaned up (Error handling). This initial commit is a work in progress to improve the mailer code. Currently done: - SMTP keep-alive - Using gomail for SMTP handling - Multiple parallel mail routines - Initial cleanup and split up into multiple files. - Added several TODOs. - Sendmail code has been adjusted. Any thoughts or ideas? Thanks! --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-02 12:02:29 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#16108