0
0
mirror of https://gitea.com/gitea/docs.git synced 2025-05-31 02:40:44 +00:00
Files
appleboy dbfa0ba454 docs: add zh-tw folder (#195)
Signed-off-by: appleboy <appleboy.tw@gmail.com>
Reviewed-on: https://gitea.com/gitea/docs/pulls/195
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: appleboy <appleboy.tw@gmail.com>
Co-committed-by: appleboy <appleboy.tw@gmail.com>
2025-04-04 23:28:16 +00:00

116 lines
4.7 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
date: "2019-10-15T10:10:00+05:00"
slug: "email-setup"
sidebar_position: 12
aliases:
- /zh-tw/email-setup
---
# 電子郵件設置
Gitea 具有發送交易電子郵件(如註冊確認)的郵件功能。它可以配置為使用 Sendmail或兼容的 MTA如 Postfix 和 msmtp或直接使用 SMTP 服務器。
## 使用 Sendmail
使用 `sendmail` 命令作為郵件程序。
:::note
要在官方 Gitea Docker 映像中使用,請配置為 SMTP 版本(請參閱以下部分)。
:::
:::note
對於面向互聯網的網站,請參閱您的 MTA 文檔以獲取有關通過 TLS 發送電子郵件的說明。還設置 SPF、DMARC 和 DKIM DNS 記錄,以使發送的電子郵件被各種電子郵件提供商接受為合法。
:::
```ini title="app.ini"
[mailer]
ENABLED = true
FROM = gitea@mydomain.com
PROTOCOL = sendmail
SENDMAIL_PATH = /usr/sbin/sendmail
SENDMAIL_ARGS = "--" ; 大多數 "sendmail" 程序接受選項,"--" 將防止電子郵件地址被解釋為選項。
```
## 使用 SMTP
直接使用 SMTP 服務器作為中繼。此選項適用於您不想在實例上設置 MTA但您在電子郵件提供商處有帳戶的情況。
```ini title="app.ini"
[mailer]
ENABLED = true
FROM = gitea@mydomain.com
PROTOCOL = smtps
SMTP_ADDR = mail.mydomain.com
SMTP_PORT = 587
USER = gitea@mydomain.com
PASSWD = `password`
```
重新啟動 Gitea 以使配置更改生效。
要發送測試電子郵件以驗證設置,請轉到 Gitea > 站點管理 > 配置 > 摘要 -> 郵件配置。
有關完整的選項列表,請參閱 [配置備忘單](../administration/config-cheat-sheet.md)
:::note
僅當 SMTP 服務器通信使用 TLS 加密或 `HOST=localhost` 時才支持身份驗證。TLS 加密可以通過:
:::
- STARTTLS也稱為機會性 TLS通過端口 587。初始連接在明文上完成但如果服務器支持則升級為 TLS。
- SMTPS 連接SMTP over TLS通過默認端口 465。從一開始就使用 TLS 連接到服務器。
- 使用 `PROTOCOL=smtps` 強制 SMTPS 連接。(這些都稱為隱式 TLS。
這是由於 Go 內部庫對 STRIPTLS 攻擊的保護。
請注意,自 2018 年以來,[RFC8314](https://tools.ietf.org/html/rfc8314#section-3) 建議使用隱式 TLS。
### Gmail
以下配置應適用於 GMail 的 SMTP 服務器:
```ini title="app.ini"
[mailer]
ENABLED = true
HOST = smtp.gmail.com:465 ; 對於 Gitea >= 1.18.0,刪除此行
SMTP_ADDR = smtp.gmail.com
SMTP_PORT = 465
FROM = example.user@gmail.com
USER = example.user
PASSWD = `***`
PROTOCOL = smtps
```
請注意,您需要通過在 Google 帳戶上啟用 2FA 來創建和使用 [應用程序密碼](https://support.google.com/accounts/answer/185833?hl=en)。您將無法直接使用您的 Google 帳戶密碼。
### ProtonMail
此功能目前僅適用於選定的 Proton for Business 客戶以及擁有自定義域地址的 Visionary 和 Family 計劃用戶。請參閱 [ProtonMail 的 SMTP 文檔](https://proton.me/support/smtp-submission) 以獲取更多信息。此限制可以通過使用 ProtonMail Bridge 應用程序來繞過。
請注意,使用 SMTP 發送的電子郵件不是 [端到端加密](https://proton.me/support/proton-mail-encryption-explained) 的。然而,它們仍然像 Proton Mail 收件箱中的其他電子郵件一樣存儲為零訪問加密。
以下配置應適用於 ProtonMail 的 SMTP 服務器:
1. 在您的瀏覽器(或桌面應用程序)中,登錄到您的 Proton Mail 帳戶,然後選擇 **設置 → 所有設置 → Proton Mail → IMAP/SMTP → SMTP 令牌**。
2. 單擊 **生成令牌**。
3. 輸入以下詳細信息以創建新的 SMTP 令牌:
- **令牌名稱**:選擇一個令牌名稱。這僅供您參考,不會影響令牌的功能。
- **電子郵件地址**:選擇一個活動的自定義域地址與您的令牌配對。複製此電子郵件地址並將其用於 `app.ini` 中的 `FROM` 和 `USER` 配置。
4. 單擊 **生成**。
5. 輸入您的 Proton Mail 帳戶密碼。
您的 SMTP 用戶名和 SMTP 令牌(密碼)將生成。您現在可以將它們作為 `USER` 和 `PASSWD` 輸入到您的 `app.ini` 配置中。
```ini title="app.ini"
[mailer]
ENABLED = true
FROM = example.user@customdomain.tld
PROTOCOL = smtp+starttls
SMTP_ADDR = smtp.protonmail.ch
SMTP_PORT = 587
USER = example.user@customdomain.tld
PASSWD = `TOKEN`
```
關閉彈出窗口後,出於安全原因,您將無法再次看到此 SMTP 令牌(密碼)。如果需要旋轉密碼,您可以隨時生成更多令牌。
注意:您的 Proton Mail 登錄或郵箱密碼將無法與 SMTP 一起使用。