Testmail function won't work with Sendmail config #359

Closed
opened 2025-11-02 03:20:04 -06:00 by GiteaMirror · 13 comments
Owner

Originally created by @Thorsten2k3 on GitHub (Feb 15, 2017).

  • Gitea version (or commit ref): 1.0.1
  • Git version: 2.7.4
  • Operating system: Ubuntu 16.04.2 LTS
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

Sending a Testmail won't work with a sendmail config. It reports an issue with the host-address, that's it.
I did some diging my self and it looks like the test-email function use 'gomail.send' instead of 'mailer.send'.
I can barely read Go, but i guess thats a mishab?

See 'models/mail.go:43'


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Originally created by @Thorsten2k3 on GitHub (Feb 15, 2017). - Gitea version (or commit ref): 1.0.1 - Git version: 2.7.4 - Operating system: Ubuntu 16.04.2 LTS - Database (use `[x]`): - [ ] PostgreSQL - [x] MySQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [x] Not relevant - Log gist: ## Description Sending a Testmail won't work with a sendmail config. It reports an issue with the host-address, that's it. I did some diging my self and it looks like the test-email function use 'gomail.send' instead of 'mailer.send'. I can barely read Go, but i guess thats a mishab? See 'models/mail.go:43' <bountysource-plugin> --- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/42067421-testmail-function-won-t-work-with-sendmail-config?utm_campaign=plugin&utm_content=tracker%2F47456670&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F47456670&utm_medium=issues&utm_source=github). </bountysource-plugin>
GiteaMirror added the type/bug label 2025-11-02 03:20:04 -06:00
Author
Owner

@plessbd commented on GitHub (Feb 15, 2017):

test mail works for me. What is your configuration?
You have to specify the host and port

[mailer]
ENABLED = true
HOST    = localhost:25
FROM    = "Gitea Instance" <gitea@domain.com>
USER    =
PASSWD  =
@plessbd commented on GitHub (Feb 15, 2017): test mail works for me. What is your configuration? You have to specify the host and port ``` [mailer] ENABLED = true HOST = localhost:25 FROM = "Gitea Instance" <gitea@domain.com> USER = PASSWD = ```
Author
Owner

@Thorsten2k3 commented on GitHub (Feb 15, 2017):

My config (minus all comments ect.)

[mailer]
ENABLED = true
SUBJECT = %(APP_NAME)s
FROM = XXX Gitea gitea@xxx
USE_SENDMAIL = true
SENDMAIL_PATH = /usr/sbin/sendmail

And echo "Subject: test"| sendmail from cmd works.

@Thorsten2k3 commented on GitHub (Feb 15, 2017): My config (minus all comments ect.) [mailer] ENABLED = true SUBJECT = %(APP_NAME)s FROM = XXX Gitea <gitea@xxx> USE_SENDMAIL = true SENDMAIL_PATH = /usr/sbin/sendmail And _echo "Subject: test"| sendmail_ from cmd works.
Author
Owner

@plessbd commented on GitHub (Feb 15, 2017):

can you turn up the log level (generally I use TRACE for debugging) and see if there is any extra information in the logs?

@plessbd commented on GitHub (Feb 15, 2017): can you turn up the log level (generally I use TRACE for debugging) and see if there is any extra information in the logs?
Author
Owner

@Thorsten2k3 commented on GitHub (Feb 15, 2017):

well, not too much to see there:

2017/02/15 21:14:33 [T] Custom path: /opt/gitea/bin/custom
2017/02/15 21:14:33 [T] Log path: /var/log/gitea/
2017/02/15 21:14:33 [I] Gitea v1.0.1
2017/02/15 21:14:33 [I] Log Mode: File(Info)
2017/02/15 21:14:33 [I] Cache Service Enabled
2017/02/15 21:14:33 [I] Session Service Enabled
2017/02/15 21:14:33 [I] Mail Service Enabled
2017/02/15 21:14:33 [I] Git Version: 2.7.4
2017/02/15 21:14:33 [I] SQLite3 Supported
2017/02/15 21:14:33 [I] Run Mode: Production
2017/02/15 21:14:33 [T] Doing: CheckRepoStats
2017/02/15 21:14:33 [I] Listen: http://127.0.0.1:3000/gitea
[Macaron] 2017-02-15 21:14:37: Started GET /admin/config for XXX
2017/02/15 21:14:37 [D] Session ID: XXX
2017/02/15 21:14:37 [D] CSRF Token: XXX
[Macaron] 2017-02-15 21:14:37: Completed /admin/config 200 OK in 15.143061ms
2017/02/15 21:14:37 [D] Template: admin/config
[Macaron] 2017-02-15 21:14:43: Started POST /admin/config/test_mail for XXX
2017/02/15 21:14:43 [D] Session ID: XXX
2017/02/15 21:14:43 [D] CSRF Token: XXX
2017/02/15 21:14:43 [T] NewMessageFrom (htmlBody):
Gitea Test Email!
[Macaron] 2017-02-15 21:14:43: Completed /admin/config/test_mail 302 Found in 6.966764ms
[Macaron] 2017-02-15 21:14:43: Started GET /admin/config for XXX
2017/02/15 21:14:43 [D] Session ID: XXX
2017/02/15 21:14:43 [D] CSRF Token: XXX
[Macaron] 2017-02-15 21:14:43: Completed /admin/config 200 OK in 10.678767ms
2017/02/15 21:14:43 [D] Template: admin/config

UI says:
Fail to send test email to 'XXX@XXX': gomail: could not send email 1: dial tcp [::1]:587: getsockopt: connection refused

I tried file as console, both logs turn out the same. (Yes it says File(Info), but File(Trace) is the same and i turned console log to trace as well, no change)

P.S. Well the code doesn't seem to log the error, all we get is what the ui says see https://github.com/go-gitea/gitea/blob/master/routers/admin/admin.go#L179

@Thorsten2k3 commented on GitHub (Feb 15, 2017): well, not too much to see there: ``` 2017/02/15 21:14:33 [T] Custom path: /opt/gitea/bin/custom 2017/02/15 21:14:33 [T] Log path: /var/log/gitea/ 2017/02/15 21:14:33 [I] Gitea v1.0.1 2017/02/15 21:14:33 [I] Log Mode: File(Info) 2017/02/15 21:14:33 [I] Cache Service Enabled 2017/02/15 21:14:33 [I] Session Service Enabled 2017/02/15 21:14:33 [I] Mail Service Enabled 2017/02/15 21:14:33 [I] Git Version: 2.7.4 2017/02/15 21:14:33 [I] SQLite3 Supported 2017/02/15 21:14:33 [I] Run Mode: Production 2017/02/15 21:14:33 [T] Doing: CheckRepoStats 2017/02/15 21:14:33 [I] Listen: http://127.0.0.1:3000/gitea [Macaron] 2017-02-15 21:14:37: Started GET /admin/config for XXX 2017/02/15 21:14:37 [D] Session ID: XXX 2017/02/15 21:14:37 [D] CSRF Token: XXX [Macaron] 2017-02-15 21:14:37: Completed /admin/config 200 OK in 15.143061ms 2017/02/15 21:14:37 [D] Template: admin/config [Macaron] 2017-02-15 21:14:43: Started POST /admin/config/test_mail for XXX 2017/02/15 21:14:43 [D] Session ID: XXX 2017/02/15 21:14:43 [D] CSRF Token: XXX 2017/02/15 21:14:43 [T] NewMessageFrom (htmlBody): Gitea Test Email! [Macaron] 2017-02-15 21:14:43: Completed /admin/config/test_mail 302 Found in 6.966764ms [Macaron] 2017-02-15 21:14:43: Started GET /admin/config for XXX 2017/02/15 21:14:43 [D] Session ID: XXX 2017/02/15 21:14:43 [D] CSRF Token: XXX [Macaron] 2017-02-15 21:14:43: Completed /admin/config 200 OK in 10.678767ms 2017/02/15 21:14:43 [D] Template: admin/config ``` UI says: `Fail to send test email to 'XXX@XXX': gomail: could not send email 1: dial tcp [::1]:587: getsockopt: connection refused` I tried file as console, both logs turn out the same. (Yes it says File(Info), but File(Trace) is the same and i turned console log to trace as well, no change) P.S. Well the code doesn't seem to log the error, all we get is what the ui says see https://github.com/go-gitea/gitea/blob/master/routers/admin/admin.go#L179
Author
Owner

@lunny commented on GitHub (Feb 22, 2017):

It seems your smtp server cannot be visited?

@lunny commented on GitHub (Feb 22, 2017): It seems your smtp server cannot be visited?
Author
Owner

@Thorsten2k3 commented on GitHub (Feb 22, 2017):

There is no smtp server. It's a sendmail config and the MTA of the Server should handle it.

I guess the sendmail config gets ignored by the Testmail function.
See in https://github.com/go-gitea/gitea/blob/master/models/mail.go#L43
The 'mailer.Sender' part should tell the whole thing, as far i understand now, to use 'Sendmail' but seems to not.

@Thorsten2k3 commented on GitHub (Feb 22, 2017): There is no smtp server. It's a sendmail config and the MTA of the Server should handle it. I guess the sendmail config gets ignored by the Testmail function. See in https://github.com/go-gitea/gitea/blob/master/models/mail.go#L43 The 'mailer.Sender' part should tell the whole thing, as far i understand now, to use 'Sendmail' but seems to not.
Author
Owner

@lunny commented on GitHub (Feb 22, 2017):

Yes. I see. Could you send a PR to fix that?

@lunny commented on GitHub (Feb 22, 2017): Yes. I see. Could you send a PR to fix that?
Author
Owner

@lunny commented on GitHub (Feb 24, 2017):

mailer.Sender is an interface. The code looks great. You can see at https://github.com/go-gitea/gitea/blob/master/modules/mailer/mailer.go#L200 . I have no idea. @couling maybe you can give some idea?

@lunny commented on GitHub (Feb 24, 2017): `mailer.Sender` is an interface. The code looks great. You can see at https://github.com/go-gitea/gitea/blob/master/modules/mailer/mailer.go#L200 . I have no idea. @couling maybe you can give some idea?
Author
Owner

@couling commented on GitHub (Feb 24, 2017):

Hey folks. I've had to take some time away for personal reasons but I may get chance to investigate this on the weekend.

The code uses send mail -F gite@example.com -i
See line 209

@thorston2k3 could you you double check your send mail accepts these args. Also make sure there is a valid To: address in the recipient field.

Can you confirm that you are sending to valid email addresses (user@domain) and not just host users. (Without the @domain)

@couling commented on GitHub (Feb 24, 2017): Hey folks. I've had to take some time away for personal reasons but I may get chance to investigate this on the weekend. The code uses `send mail -F gite@example.com -i` See line 209 @thorston2k3 could you you double check your send mail accepts these args. Also make sure there is a valid To: address in the recipient field. Can you confirm that you are sending to valid email addresses (user@domain) and not just host users. (Without the @domain)
Author
Owner

@Thorsten2k3 commented on GitHub (Feb 24, 2017):

sendmail -F gitea@example.com -i my.email@addressl.com works fine, mail gets to my account as it should.
MTA is an exim4 ( lrwxrwxrwx 1 root root 5 Jan 5 15:50 /usr/sbin/sendmail -> exim4 )
I just got the dev env running, in case i find the error my self i'll report and present a PR.

@Thorsten2k3 commented on GitHub (Feb 24, 2017): `sendmail -F gitea@example.com -i my.email@addressl.com` works fine, mail gets to my account as it should. MTA is an exim4 ( lrwxrwxrwx 1 root root 5 Jan 5 15:50 /usr/sbin/sendmail -> exim4 ) I just got the dev env running, in case i find the error my self i'll report and present a PR.
Author
Owner

@lunny commented on GitHub (Mar 1, 2017):

@Thorsten2k3 any update? Maybe we could move this to v1.2?

@lunny commented on GitHub (Mar 1, 2017): @Thorsten2k3 any update? Maybe we could move this to v1.2?
Author
Owner

@Thorsten2k3 commented on GitHub (Mar 1, 2017):

hadn't got the time to look in to it yet. if it boils down to me doing the work i don't mind moving it to 1.2

@Thorsten2k3 commented on GitHub (Mar 1, 2017): hadn't got the time to look in to it yet. if it boils down to me doing the work i don't mind moving it to 1.2
Author
Owner

@lunny commented on GitHub (Dec 12, 2017):

It seems this has been fixed some time by some PR. Please feel free to reopen it.

@lunny commented on GitHub (Dec 12, 2017): It seems this has been fixed some time by some PR. Please feel free to reopen it.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#359