Skip to content

feat(email): 新增可选的 from 字段用于设置发件地址#378

Open
rustupup wants to merge 1 commit into
zdz:masterfrom
rustupup:feat/email-from-field
Open

feat(email): 新增可选的 from 字段用于设置发件地址#378
rustupup wants to merge 1 commit into
zdz:masterfrom
rustupup:feat/email-from-field

Conversation

@rustupup

Copy link
Copy Markdown

部分邮件服务商(如 SendGrid)的 SMTP 登录账号使用 API Key,
与实际的发件邮箱地址不同,因此需要单独配置发件人。
新增可选的 from 字段,未指定时回退使用 username 作为发件地址。

部分邮件服务商(如 SendGrid)的 SMTP 登录账号使用 API Key,
与实际的发件邮箱地址不同,因此需要单独配置发件人。
新增可选的 `from` 字段,未指定时回退使用 `username` 作为发件地址。

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

该 PR 为邮件通知新增可选的 from 配置,用于在 SMTP 登录账号(username)不是实际发件邮箱(例如使用 API Key 登录)时,单独指定发件人地址;未指定时回退使用 username

Changes:

  • 在邮件通知配置中新增 from: Option<String> 字段。
  • 发送邮件时优先使用 from 作为发件地址,否则回退到 username
  • 更新 config.toml 示例与说明,增加 from 字段的配置注释。

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
server/src/notifier/email.rs 新增 from 配置读取,并用于构造邮件 From 头部
config.toml 增加 from 的配置说明与示例注释

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread server/src/notifier/email.rs
Comment thread config.toml
Comment on lines +120 to +122
# 可选:发件人邮箱地址。
# 部分服务商(如 SendGrid)SMTP 登录账号(username)为 API Key 而非邮箱地址,
# 此时需在此填写真实发件邮箱;留空则默认使用 username 作为发件地址。
@zdz

zdz commented Jul 11, 2026

Copy link
Copy Markdown
Owner

把 from 的内容直接填入 username ,代码上看效果一样

@rustupup

Copy link
Copy Markdown
Author

把 from 的内容直接填入 username ,代码上看效果一样

不一样,当 username 不是合法的邮箱格式时,lettre 会报错。例如.from(format!("ServerStatus <{}>", "d2ADdhhXS8SzwWEr2Xg").parse().unwrap());,报错:called Result::unwrap() on an Err value: InvalidInput

@zdz

zdz commented Jul 11, 2026

Copy link
Copy Markdown
Owner

username 填写 正确合法的邮箱格式 应该满足你的需求吧,当 username 填写正确的邮件格式时,这两个代码看上去是作用是一样的

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.

3 participants