-
-
Notifications
You must be signed in to change notification settings - Fork 6k
Description
Gitea Version
1.15.7
Git Version
No response
Operating System
alpine linux (using the official gitea docker image)
How are you running Gitea?
Through the official gitea docker image
Database
PostgreSQL
Can you reproduce the bug on the Gitea demo site?
No
Log Gist
https://gist.github.com/ben-kenney/8fc6715ffd2a6c5721469772957dba2e
Description
I've configured my gitea to use sendmail. I receive email notifications but they are all missing the message body and only contain the subject line.
When I log into my gitea docker container and manually check to see if sendmail is working, I can confirm that sendmail does work BUT it requires a blank line between the subject and the message body, like this:
$ sendmail -S mail.host.com recipient@domain.com
Subject: this is the subject
The message body only appears if it follows a blank line.
The blank line before the message body appears to be important otherwise sendmail will not inlcude the message body, this is documented elsewhere (sorry I couldn't find anything more official than the linked response).
I'm curious to know if this could be the reason why I'm not able to see the email messages from gitea.
I think that emails such as this test email from gitea should likely need \n\n
in front of the message body when using sendmail.
return gomail.Send(Sender, NewMessage([]string{email}, "Gitea Test Email!", "Gitea Test Email!").ToMessage())
Screenshots
Here's a screenshot of the email that I received from gitea after posting a test comment (note that the message body is blank).
Activity
zeripath commentedon Dec 19, 2021
It would be useful to see your configuration.
[mailer]
section in your app.ini?wxiaoguang commentedon Dec 19, 2021
It isn't that simple. Can you check the original message of the email you received and post it here?
If you run:
You will find the output, this is what you should see in your original message.
zeripath commentedon Dec 19, 2021
... or set "MAILER_TYPE=dummy" in app.ini
ben-kenney commentedon Dec 19, 2021
@zeripath Here is my app.ini:
when I set
MAILER_TYPE = dummy
, the logs show this:I'll need to google what
\01503d
is. If it represents a "blank line" then my theory isn't correct.Here's the header from the received email that I get (there's no mention of the Gitea Test Email! message body):
Not sure if this is the issue but it goes through a MS exchange server. I suspect the MS exchange is not the issue because when I try this manually using the
sendmail
from the command line from within the docker container I can reproduce this issue (and also confirm that a blank line works).zeripath commentedon Dec 19, 2021
What package is providing the /usr/sbin/sendmail command?
As I said above I'm almost certain that this is not going to be sendmail but rather some other package that provides a sendmail command.
ben-kenney commentedon Dec 19, 2021
I guess I thought gitea was the package that is providing the sendmail command. There are references to sendmail in the gitea code.
from the logs that I have it looks like it is using sendmail:
zeripath commentedon Dec 19, 2021
So it's the sendmail provided by busybox
zeripath commentedon Dec 19, 2021
The \01503d is \015. The 03d is simply due to a bug in the logger which I will fix imminently.
\015 => \r so you can see that the blank line is being passed to "sendmail"
zeripath commentedon Dec 19, 2021
In your testcase are you sending lines with \r\n?
ben-kenney commentedon Dec 19, 2021
First of all, thank you for looking into this! And now I realize what you were asking regarding the package manager.
No, in my test case I was invoking sendmail from the command line, not piping any text to sendmail. I literally just type this:
What I think is happening is that \n should be used instead of \r, only reason why I say this is because on my linux terminal when I run
printf "hello \n world"
the output makes a lot more sense to me thanprintf "hello \r world"
zeripath commentedon Dec 19, 2021
The RFC disagrees with you.
Lines have to be terminated with \r\n for SMTP.
zeripath commentedon Dec 19, 2021
Why aren't you simply using the SMTP mailer directly? If you're just using the sendmail command on the docker AFAICS it's just using SMTP itself and it is not in itself a mailer daemon.
ben-kenney commentedon Dec 19, 2021
I started off with SMTP but got autehntication failures. sendmail works for me from the command line and comes close to working
for me with gitea except I don't see the message body.
zeripath commentedon Dec 19, 2021
Well it appears your chosen sendmail command doesn't appear to obey the standard. You could try catting a crlf'd message to it to prove that's the problem. If it is then you might have to write a script that will strip out the CRs or...
Given your sendmail command is not doing anything different from what gitea can do I think you should work out why you were getting authentication problems with the SMTP backend or at least give us some more information as to what kind of authentication problems you were getting
13 remaining items