Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sendmail does not work / doesn't use FROM parameter #9385

Closed
2 of 7 tasks
DeveloperOl opened this issue Dec 17, 2019 · 2 comments · Fixed by #9961
Closed
2 of 7 tasks

sendmail does not work / doesn't use FROM parameter #9385

DeveloperOl opened this issue Dec 17, 2019 · 2 comments · Fixed by #9961

Comments

@DeveloperOl
Copy link

DeveloperOl commented Dec 17, 2019

  • Gitea version (or commit ref): 1.10.1
  • Git version: 2.11.0
  • Operating system: Raspbian / Debian 9 (Stretch)
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

I tried to setup email notifications with postfix sendmail using the following config:

ENABLED = true
FROM = My Gitea <noreply@gitea.[mydomain].io>
MAILER_TYPE = sendmail

[mydomain] is replaced with a valid domain.

But when I send a test mail postfix logs this:

Dec 17 14:44:19 RaspberryPi postfix/cleanup[3590]: 6246C1006F3: message-id=<20191217134419.6246C1006F3@mail.[mydomain].io>
Dec 17 14:44:19 RaspberryPi postfix/qmgr[3499]: 6246C1006F3: from=<git@notification@RaspberryPi.com>, size=899, nrcpt=1 (queue active)
Dec 17 14:44:19 RaspberryPi postfix/smtp[3592]: 6246C1006F3: to=<[anonymized]@gmail.com>, relay=gmail-smtp-in.l.google.com[108.177.126.27]:25, delay=0.57, delays=0.1/0.03/0.43/0.01, dsn=5.1.7, status=bounced (host gmail-smtp-in.l.google.com[108.177.126.27] said: 553-5.1.7 The sender address <git@notification@raspberrypi.com> is not a valid 553 5.1.7 RFC-5321 address. v25si7275410edq.184 - gsmtp (in reply to MAIL FROM command))
Dec 17 14:44:19 RaspberryPi postfix/cleanup[3590]: EF6DA100746: message-id=<20191217134419.EF6DA100746@mail.[mydomain].io>
Dec 17 14:44:20 RaspberryPi postfix/bounce[3593]: 6246C1006F3: sender non-delivery notification: EF6DA100746
Dec 17 14:44:20 RaspberryPi postfix/qmgr[3499]: EF6DA100746: from=<>, size=3248, nrcpt=1 (queue active)
Dec 17 14:44:20 RaspberryPi postfix/qmgr[3499]: 6246C1006F3: removed
Dec 17 14:44:20 RaspberryPi postfix/smtp[3592]: EF6DA100746: to=<git@notification@RaspberryPi.com>, relay=none, delay=0.13, delays=0.03/0.01/0.1/0, dsn=5.4.4, status=bounced (Host or domain name not found. Name service error for name=raspberrypi.com type=AAAA: Host not found)
Dec 17 14:44:20 RaspberryPi postfix/qmgr[3499]: EF6DA100746: removed

and I don't receive an email. I can see that my configured FROM = My Gitea <noreply@gitea.[mydomain].io> is not beeing used and therefore the email gets rejected by gmail.
The sendmail works fine for my nextcloud setup

@zeripath
Copy link
Contributor

Looking at the code it certainly appears to set it.

MailService.From = sec.Key("FROM").MustString(MailService.User)

parsed, err := mail.ParseAddress(MailService.From)
if err != nil {
log.Fatal("Invalid mailer.FROM (%s): %v", MailService.From, err)
}
MailService.FromName = parsed.Name
MailService.FromEmail = parsed.Address
if MailService.MailerType == "" {
MailService.MailerType = "smtp"
}

And use it:

return NewMessageFrom(to, setting.MailService.FromName, setting.MailService.FromEmail, subject, body)

msg := NewMessageFrom([]string{to}, ctx.Doer.DisplayName(), setting.MailService.FromEmail, subject, mailBody.String())

Used here:

msg.SetAddressHeader("From", fromAddress, fromDisplayName)

Leading to:

args := []string{"-F", from, "-i"}

Try setting the MAILER_TYPE=dummy just to ensure that the from address is being parsed correctly.

If that is correct then we need to think a bit more about where it could be going wrong.

@DeveloperOl
Copy link
Author

@zeripath using "dummy" as MAILER_TYPE results in the expected result:

	From: "My Gitea" <noreply@gitea.[mydomain].io>\01503d
	To: [anonymized]@gmail.com\01503d
	Subject: Gitea Test Email!\01503d
	Date: Thu, 19 Dec 2019 11:51:36 +0100\01503d
	X-Auto-Response-Suppress: All\01503d
	Content-Type: multipart/alternative;\01503d
	 boundary=96fa55d689ea616bc3979cbf55f1f74f14c7cd681734450a819b58124e80\01503d
	\01503d
	--96fa55d689ea616bc3979cbf55f1f74f14c7cd681734450a819b58124e80\01503d
	Content-Transfer-Encoding: quoted-printable\01503d
	Content-Type: text/plain; charset=UTF-8\01503d
	\01503d
	Gitea Test Email!\01503d
	--96fa55d689ea616bc3979cbf55f1f74f14c7cd681734450a819b58124e80\01503d
	Content-Transfer-Encoding: quoted-printable\01503d
	Content-Type: text/html; charset=UTF-8\01503d
	\01503d
	Gitea Test Email!\01503d
	--96fa55d689ea616bc3979cbf55f1f74f14c7cd681734450a819b58124e80--\01503d

I have narrowed the error down to the parameter -F.
using echo "Subject: sendmail test" | sendmail -F "My Gitea <noreply@gitea.[mydomain].io>" -v "[anonymized]@gmail.com" does not work and results in from=<git@notification@RaspberryPi.com> beeing used by sendmail. Using the parameter -f (Subject: sendmail test" | sendmail -f "My Gitea <noreply@gitea.[mydomain].io>" -v "[anonymized]@gmail.com" fixes my issue.

zeripath added a commit to zeripath/gitea that referenced this issue Jan 24, 2020
techknowlogick pushed a commit to techknowlogick/gitea that referenced this issue Jan 24, 2020
techknowlogick added a commit that referenced this issue Jan 25, 2020
Fix #9385

Co-authored-by: zeripath <art27@cantab.net>
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants