SMTP authentication failing #10906

Closed
opened 2025-11-02 09:21:48 -06:00 by GiteaMirror · 4 comments
Owner

Originally created by @clmcavaney on GitHub (May 24, 2023).

Description

I am running Gitea as a docker container.
In the past I have been able to use a SMTP server with authentication successfully.
I have recently had to change SMTP providers and now am getting this error message when I am testing email:

Failed to send a testing email to "<redacted>": gomail: could not send email 1: failed to authenticate SMTP: 535 5.7.8 Error: authentication failed: authentication failure

I have looked into the debugs, but there are not many around the email process.
I have also tried another go based CLI mail program (github.com/kiwimic/mailCLI) to see if the SMTP service is working with the same SMTP credentials as I have configured for Gitea.
That CLI worked.

I also tested with the swaks CLI tool with the same SMTP credentials, and it worked too.

So, I am wondering why Gitea isn't working. Is there a way to get more debugging information out of Gitea? I have set the log level to DEBUG, but it isn't including things like what attributes it is passing to the SMTP service or anything like that.
I am wondering if it is a string encoding issue or something that is causing the SMTP server to say authentication failure.

Any assistance would be fantastic - I'm happy to diagnose further, I am not as familiar with go as with other languages.

Gitea Version

1.20.0+dev-888-g64e0672e3

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

This is the only console log about the test email:
gitea | 2023/05/24 15:41:13 ...eb/routing/logger.go:102:func1() [I] router: completed POST /admin/config/test_mail for []:0, 303 See Other in 2924.0ms @ admin/config.go:31(admin.SendTestMail)

Git Version

git version 2.40.1

Operating System

Docker container

How are you running Gitea?

Within a Docker container using the gitea/gitea:nightly release.
I used nightly to see if the isn't had been resolved in the latest version.
docker-compose.yml contains:

...
      - GITEA__mailer__PROTOCOL=smtp+starttls
      - GITEA__mailer__SMTP_PORT=587
      - GITEA__mailer__IS_TLS_ENABLED=true
      # shouldn't need this but giving it a try
      - GITEA__mailer__FORCE_TRUST_SERVER_CERT=false
      - GITEA__mailer__FROM=<redacted>
      - GITEA__mailer__USER=<redacted>
      - 'GITEA__mailer__SUBJECT_PREFIX=GITEA: '
      - GITEA__mailer__PASSWD=`<redacted>`
...

Database

MySQL

Originally created by @clmcavaney on GitHub (May 24, 2023). ### Description I am running Gitea as a docker container. In the past I have been able to use a SMTP server with authentication successfully. I have recently had to change SMTP providers and now am getting this error message when I am testing email: ``` Failed to send a testing email to "<redacted>": gomail: could not send email 1: failed to authenticate SMTP: 535 5.7.8 Error: authentication failed: authentication failure ``` I have looked into the debugs, but there are not many around the email process. I have also tried another go based CLI mail program ([github.com/kiwimic/mailCLI](github.com/kiwimic/mailCLI)) to see if the SMTP service is working with the same SMTP credentials as I have configured for Gitea. That CLI worked. I also tested with the `swaks` CLI tool with the same SMTP credentials, and it worked too. So, I am wondering why Gitea isn't working. Is there a way to get more debugging information out of Gitea? I have set the log level to DEBUG, but it isn't including things like what attributes it is passing to the SMTP service or anything like that. I am wondering if it is a string encoding issue or something that is causing the SMTP server to say `authentication failure`. Any assistance would be fantastic - I'm happy to diagnose further, I am not as familiar with `go` as with other languages. ### Gitea Version 1.20.0+dev-888-g64e0672e3 ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist _No response_ ### Screenshots This is the only console log about the test email: gitea | 2023/05/24 15:41:13 ...eb/routing/logger.go:102:func1() [I] router: completed POST /admin/config/test_mail for [<redacted>]:0, 303 See Other in 2924.0ms @ admin/config.go:31(admin.SendTestMail) ### Git Version git version 2.40.1 ### Operating System Docker container ### How are you running Gitea? Within a Docker container using the `gitea/gitea:nightly` release. I used `nightly` to see if the isn't had been resolved in the latest version. `docker-compose.yml` contains: ``` ... - GITEA__mailer__PROTOCOL=smtp+starttls - GITEA__mailer__SMTP_PORT=587 - GITEA__mailer__IS_TLS_ENABLED=true # shouldn't need this but giving it a try - GITEA__mailer__FORCE_TRUST_SERVER_CERT=false - GITEA__mailer__FROM=<redacted> - GITEA__mailer__USER=<redacted> - 'GITEA__mailer__SUBJECT_PREFIX=GITEA: ' - GITEA__mailer__PASSWD=`<redacted>` ... ``` ### Database MySQL
GiteaMirror added the type/question label 2025-11-02 09:21:48 -06:00
Author
Owner

@wxiaoguang commented on GitHub (May 24, 2023):

Can you manually check your "app.ini" to see whether the options are right there?

gitea.com is also using the nightly and it also sends emails, it works there.

@wxiaoguang commented on GitHub (May 24, 2023): Can you manually check your "app.ini" to see whether the options are right there? gitea.com is also using the nightly and it also sends emails, it works there.
Author
Owner

@clmcavaney commented on GitHub (May 24, 2023):

G'day @wxiaoguang,
Thanks for the prompt response.
I was able to check that and had found that the environment variables from the docker-compose.yml hadn't come through correctly.
I have made some adjustments and I think it may be working now.
I will update for sure once I can confirm.

@clmcavaney commented on GitHub (May 24, 2023): G'day @wxiaoguang, Thanks for the prompt response. I was able to check that and had found that the environment variables from the `docker-compose.yml` hadn't come through correctly. I have made some adjustments and I think it may be working now. I will update for sure once I can confirm.
Author
Owner

@clmcavaney commented on GitHub (May 24, 2023):

I can confirm that this is working.

From what I can determine the issue was twfold.

One, is that there is two configuration items for essentially the same thing:
GITEA__mailer__HOST which is a combination of GITEA__mailer__SMTP_ADDR and GITEA__mailer__SMTP_PORT.
If I only configure GITEA__mailer__HOST email fails to send.
I have to configure both the HOST, SMTP_ADDR, and SMTP_PORT values.

Why is this?

I read the documentation as HOST would take priority over SMTP_ADDR and SMTP_PORT - but maybe it is the other way round.

I think the issue there could be that if SMTP_ADDR and SMTP_PORT is supplied, and HOST is not, any existing HOST value in the app.ini file isn't removed. (NOTE: There is an existing app.ini file as there is a persistent volume specified in the docker-compose.yml file.

Two, escaping the password value. Once I realised I was able to see the app.ini file in the Docker container, I was able to ascertain that the password had not been configured correctly.

Thanks again for your quick response @wxiaoguang

@clmcavaney commented on GitHub (May 24, 2023): I can confirm that this is working. From what I can determine the issue was twfold. **One**, is that there is two configuration items for essentially the same thing: `GITEA__mailer__HOST` which is a combination of `GITEA__mailer__SMTP_ADDR` and `GITEA__mailer__SMTP_PORT`. If I only configure `GITEA__mailer__HOST` email fails to send. I have to configure both the `HOST`, `SMTP_ADDR`, and `SMTP_PORT` values. Why is this? I read the documentation as `HOST` would take priority over `SMTP_ADDR` and `SMTP_PORT` - but maybe it is the other way round. I think the issue there could be that if `SMTP_ADDR` and `SMTP_PORT` is supplied, and `HOST` is not, any existing `HOST` value in the `app.ini` file isn't removed. (NOTE: There is an existing `app.ini` file as there is a persistent volume specified in the `docker-compose.yml` file. **Two**, escaping the password value. Once I realised I was able to see the `app.ini` file in the Docker container, I was able to ascertain that the password had not been configured correctly. Thanks again for your quick response @wxiaoguang
Author
Owner

@wxiaoguang commented on GitHub (Jul 14, 2025):

I have to configure both the HOST, SMTP_ADDR, and SMTP_PORT values.

IIRC some of the options were deprecated, there should be some logs mentioning it.

@wxiaoguang commented on GitHub (Jul 14, 2025): > I have to configure both the `HOST`, `SMTP_ADDR`, and `SMTP_PORT` values. IIRC some of the options were deprecated, there should be some logs mentioning it.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#10906