2019-10-16 16:34:20 +05:00
---
date : "2019-10-15T10:10:00+05:00"
2023-04-06 17:06:32 +08:00
title : "Email setup"
2019-10-16 16:34:20 +05:00
slug : "email-setup"
2023-07-25 21:00:14 -05:00
sidebar_position : 12
2020-12-09 07:47:06 +01:00
toc : false
2019-10-16 16:34:20 +05:00
draft : false
2023-04-27 22:33:41 -05:00
aliases :
- /en-us/email-setup
2019-10-16 16:34:20 +05:00
menu :
sidebar :
2023-03-23 23:18:24 +08:00
parent : "administration"
2019-10-16 16:34:20 +05:00
name : "Email setup"
2023-07-25 21:00:14 -05:00
sidebar_position : 12
2019-10-16 16:34:20 +05:00
identifier : "email-setup"
---
# Email setup
2021-07-13 03:05:40 +07:00
Gitea has mailer functionality for sending transactional emails (such as registration confirmation). It can be configured to either use Sendmail (or compatible MTAs like Postfix and msmtp) or directly use SMTP server.
2019-10-16 16:34:20 +05:00
2021-07-13 03:05:40 +07:00
## Using Sendmail
2020-12-09 07:47:06 +01:00
2021-07-13 03:05:40 +07:00
Use `sendmail` command as mailer.
2024-06-07 18:03:08 +08:00
For use in the official Gitea Docker image, please configure with the SMTP version (see the following section).
2021-07-13 03:05:40 +07:00
2024-06-07 18:03:08 +08:00
:::note
For Internet-facing sites consult documentation of your MTA for instructions to send emails over TLS. Also set up SPF, DMARC, and DKIM DNS records to make emails sent be accepted as legitimate by various email providers.
:::
2020-12-09 07:47:06 +01:00
2024-06-06 22:49:46 +08:00
```ini title="app.ini"
2019-10-16 16:34:20 +05:00
[mailer]
2020-03-13 20:20:14 +05:00
ENABLED = true
FROM = gitea@mydomain.com
2023-07-26 23:55:27 +08:00
PROTOCOL = sendmail
2020-03-13 20:20:14 +05:00
SENDMAIL_PATH = /usr/sbin/sendmail
2022-03-18 14:19:02 +00:00
SENDMAIL_ARGS = "--" ; most "sendmail" programs take options, "--" will prevent an email address being interpreted as an option.
2020-03-13 20:20:14 +05:00
` ``
2021-07-13 03:05:40 +07:00
## Using SMTP
Directly use SMTP server as relay. This option is useful if you don't want to set up MTA on your instance but you have an account at email provider.
2020-12-09 07:47:06 +01:00
2024-06-06 22:49:46 +08:00
` ``ini title="app.ini"
2020-03-13 20:20:14 +05:00
[mailer]
ENABLED = true
FROM = gitea@mydomain.com
2023-07-26 23:55:27 +08:00
PROTOCOL = smtps
2022-10-31 23:02:37 +01:00
SMTP_ADDR = mail.mydomain.com
SMTP_PORT = 587
2020-03-13 20:20:14 +05:00
USER = gitea@mydomain.com
PASSWD = ` password`
2019-10-16 16:34:20 +05:00
` ``
2021-07-13 03:05:40 +07:00
Restart Gitea for the configuration changes to take effect.
2019-10-16 16:34:20 +05:00
2021-07-13 03:05:40 +07:00
To send a test email to validate the settings, go to Gitea > Site Administration > Configuration > SMTP Mailer Configuration.
2019-10-16 16:34:20 +05:00
2023-07-25 21:00:14 -05:00
For the full list of options check the [Config Cheat Sheet](administration/config-cheat-sheet.md)
2020-04-06 21:18:42 +01:00
2024-06-07 18:03:08 +08:00
:::note
Authentication is only supported when the SMTP server communication is encrypted with TLS or ` HOST=localhost`. TLS encryption can be through:
:::
2022-07-28 03:22:47 +02:00
- STARTTLS (also known as Opportunistic TLS) via port 587. Initial connection is done over cleartext, but then be upgraded over TLS if the server supports it.
- SMTPS connection (SMTP over TLS) via the default port 465. Connection to the server use TLS from the beginning.
- Forced SMTPS connection with ` IS_TLS_ENABLED=true`. (These are both known as Implicit TLS.)
2021-07-13 03:05:40 +07:00
This is due to protections imposed by the Go internal libraries against STRIPTLS attacks.
2024-06-07 18:03:08 +08:00
:::note
Implicit TLS is recommended by [RFC8314](https://tools.ietf.org/html/rfc8314#section-3) since 2018.
:::
2020-05-24 23:56:18 +01:00
2020-04-06 21:18:42 +01:00
### Gmail
The following configuration should work with GMail's SMTP server:
2024-06-06 22:49:46 +08:00
` ``ini title="app.ini"
2020-04-06 21:18:42 +01:00
[mailer]
ENABLED = true
2023-01-02 13:52:36 +11:00
HOST = smtp.gmail.com:465 ; Remove this line for Gitea >= 1.18.0
2022-10-31 23:02:37 +01:00
SMTP_ADDR = smtp.gmail.com
SMTP_PORT = 465
2023-01-02 13:52:36 +11:00
FROM = example.user@gmail.com
USER = example.user
2023-04-04 12:19:01 -05:00
PASSWD = ` ***`
2023-08-06 12:02:43 -04:00
PROTOCOL = smtps ; Gitea >= 1.19.0
; PROTOCOL = smtp ; Gitea < 1.19.0
; IS_TLS_ENABLED = true ; Gitea < 1.19.0
2020-04-06 21:18:42 +01:00
` ``
2023-01-02 13:52:36 +11:00
2024-06-07 18:03:08 +08:00
:::note
You'll need to create and use an [App password ](https://support.google.com/accounts/answer/185833?hl=en ) by enabling 2FA on your Google
2023-01-02 13:52:36 +11:00
account. You won't be able to use your Google account password directly.
2024-06-07 18:03:08 +08:00
:::