Using Gmail SMTP with gitea

I’m trying to setup Gmail SMTP with gitea. I have the following settings:

ENABLED = true
FROM = my gmail address
PROTOCOL = smtps
USER = my gmail address
PASSWD =my app password

I ran the command:

gitea admin sendmail --title “Hello from Gitea” --content “This is a test”

and got:

Proceed with sending email? [Y/n] y
Sent 1 email(s) to all users

The docker log shows:

2023/10/14 12:19:15 …eb/routing/logger.go:102:func1() [I] router: completed POST /api/internal/mail/send for, 200 OK in 10.2ms @ private/mail.go:25(private.SendEmail)

But I did not receive an email, any suggestions on what I am doing wrong or the best way to debug this issue

I changed the logging level to trace and reran and got the following output

2023/10/15 03:10:09 …s/process/manager.go:188:Add() [T] Start 652bba81: POST: /api/internal/mail/send (request)
2023/10/15 03:10:09 …eb/routing/logger.go:47:func1() [T] router: started POST /api/internal/mail/send for
2023/10/15 03:10:09 …ces/mailer/mailer.go:102:NewMessageFrom() [T] NewMessageFrom (body):
This is a test
2023/10/15 03:10:09 …eb/routing/logger.go:102:func1() [I] router: completed POST /api/internal/mail/send for, 200 OK in 5.8ms @ private/mail.go:25(private.SendEmail)
2023/10/15 03:10:09 …s/process/manager.go:231:remove() [T] Done 652bba81: POST: /api/internal/mail/send
2023/10/15 03:10:10 …queue/workergroup.go:143:func1() [D] Queue “mail” starts new worker
2023/10/15 03:10:10 …ces/mailer/mailer.go:409:func1() [T] New e-mail sending request []:
2023/10/15 03:10:10 …ces/mailer/mailer.go:411:func1() [E] Failed to send emails []: - gomail: could not send email 1: could not initiate SMTP session: tls: first record does not look like a TLS handshake

Either use:

  • PROTOCOL=smtps and SMTP_PORT=465, or
  • PROTOCOL=smtp and SMTP_PORT=587

The first one is recommended.

1 Like

Many thanks that worked.