Hoppa till innehållet

Apps

Gitea

Send the mail that Gitea writes, such as notifications of issues and pull requests, password resets and requests to confirm an address, through Sendora’s SMTP.

Before you start

  • A Sendora account. A test server works from the moment the account exists. A live server sends once your account is approved. The account starts on Free, within the limits that Account › Usage in the dashboard shows.
  • Access to the DNS of the domain that Gitea’s mail comes from.
  • Access to Gitea’s configuration file, app.ini, and a Gitea administrator’s account.

Set up Gitea

  1. Add the domain that Gitea’s mail comes from under Domains, and add the two DNS records it shows, as Domains explains.
  2. Create a test server under Servers › New server, with Testserver ticked, and create a key on its API keys tab. The key starts with sk_test_. A test server takes mail as a live server does and delivers none of it.
  3. Add these lines to app.ini, with the server key as both USER and PASSWD. In Gitea, Site Administration › Configuration › Summary shows where the file is, under Configuration File Path.
[mailer]
ENABLED = true
PROTOCOL = smtps
SMTP_ADDR = smtp.sendora.se
SMTP_PORT = 465
USER = sk_test_…
PASSWD = sk_test_…
FROM = Gitea <gitea@example.se>

Put an address on your verified domain in FROM. To email its users about issues, pull requests and comments, Gitea also needs ENABLE_NOTIFY_MAIL = true under [service].

Port 465 encrypts the connection from the first byte. Port 587 works too, with PROTOCOL = smtp+starttls. Gitea then starts TLS only if the server offers it. Line 96 of its mail code shows this in 28.4.0. If someone between Gitea and Sendora removed that offer, Gitea would send the key unencrypted, so use 465 where you can.

If Gitea runs on a host that blocks ports 465 and 587, such as a DigitalOcean Droplet, use port 2525 with PROTOCOL = smtp+starttls. Without PROTOCOL, Gitea would take 2525 for a port that encrypts from the first byte, and fail.

  1. Restart Gitea, which reads app.ini only when it starts.
  2. Open Site Administration from your user menu, then Configuration › Summary. Under Mailer Configuration, enter your address in Send Testing Email, and click Send.
  3. Find the message on the server’s Messages tab under Servers.
  4. Once your account is approved, create a key on your live server’s API keys tab, such as the default server that signup made. Put it in USER and PASSWD in place of the test key, and restart Gitea.

Gitea in Docker

Gitea’s Docker image keeps app.ini at /data/gitea/conf/app.ini, in the volume it mounts at /data. Edit the file there, and restart the container. You can also set each line as a variable in the container’s environment, named GITEA__mailer__ followed by the key, such as GITEA__mailer__SMTP_ADDR=smtp.sendora.se. Then recreate the container. The image writes the variables into app.ini when it starts.

If a message is refused

When Sendora refuses the testing email, Gitea shows Failed to send a testing email, followed by Sendora’s reply. Gitea sends the rest of its mail in the background, and its log holds Failed to send emails with Sendora’s reply. 535 5.7.8 means the key is wrong or revoked. 550 5.7.1 means the From domain is not verified, or that a live server’s account is not yet approved. 451 4.7.0 means that a limit is reached, such as Free’s daily limit. 550 5.1.1 means the recipient’s address is on the suppression list, for example after a hard bounce. SMTP replies lists every reply.

Test the setup

On the server’s API keys tab under Servers, Test the setup shows each valid key’s latest sign-in and accepted message over SMTP. It also shows the key’s latest refusals, each with what to do. After Gitea sends a message, click Check now.