feat(email): 新增可选的 from 字段用于设置发件地址#378
Open
rustupup wants to merge 1 commit into
Open
Conversation
部分邮件服务商(如 SendGrid)的 SMTP 登录账号使用 API Key, 与实际的发件邮箱地址不同,因此需要单独配置发件人。 新增可选的 `from` 字段,未指定时回退使用 `username` 作为发件地址。
Contributor
There was a problem hiding this comment.
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 on lines
+120
to
+122
| # 可选:发件人邮箱地址。 | ||
| # 部分服务商(如 SendGrid)SMTP 登录账号(username)为 API Key 而非邮箱地址, | ||
| # 此时需在此填写真实发件邮箱;留空则默认使用 username 作为发件地址。 |
3 tasks
Owner
|
把 from 的内容直接填入 username ,代码上看效果一样 |
Author
不一样,当 username 不是合法的邮箱格式时,lettre 会报错。例如.from(format!("ServerStatus <{}>", "d2ADdhhXS8SzwWEr2Xg").parse().unwrap());,报错:called |
Owner
|
username 填写 正确合法的邮箱格式 应该满足你的需求吧,当 username 填写正确的邮件格式时,这两个代码看上去是作用是一样的 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
部分邮件服务商(如 SendGrid)的 SMTP 登录账号使用 API Key,
与实际的发件邮箱地址不同,因此需要单独配置发件人。
新增可选的
from字段,未指定时回退使用username作为发件地址。