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

Closed
opened 2025-11-02 05:52:39 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @DeveloperOl on GitHub (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

Originally created by @DeveloperOl on GitHub (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 - [x] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [x] Not relevant - Log gist: ## Description I tried to setup email notifications with postfix sendmail using the following config: ```[mailer] 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/pickup[3498]: 6246C1006F3: uid=118 from=<git> 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
Author
Owner

@zeripath commented on GitHub (Dec 17, 2019):

Looking at the code it certainly appears to set it.

590d56dbb3/modules/setting/mailer.go (L74)

590d56dbb3/modules/setting/mailer.go (L88-L97)

And use it:

590d56dbb3/services/mailer/mailer.go (L67)

08ae6bb7ed/services/mailer/mail.go (L246)

Used here:

590d56dbb3/services/mailer/mailer.go (L39)

Leading to:

590d56dbb3/services/mailer/mailer.go (L216)

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.

@zeripath commented on GitHub (Dec 17, 2019): Looking at the code it certainly appears to set it. https://github.com/go-gitea/gitea/blob/590d56dbb355a499b2f59d9a6ffa4887ea33c96b/modules/setting/mailer.go#L74 https://github.com/go-gitea/gitea/blob/590d56dbb355a499b2f59d9a6ffa4887ea33c96b/modules/setting/mailer.go#L88-L97 And use it: https://github.com/go-gitea/gitea/blob/590d56dbb355a499b2f59d9a6ffa4887ea33c96b/services/mailer/mailer.go#L67 https://github.com/go-gitea/gitea/blob/08ae6bb7edb9582c38edb8a0dba1b1be10fb00fc/services/mailer/mail.go#L246 Used here: https://github.com/go-gitea/gitea/blob/590d56dbb355a499b2f59d9a6ffa4887ea33c96b/services/mailer/mailer.go#L39 Leading to: https://github.com/go-gitea/gitea/blob/590d56dbb355a499b2f59d9a6ffa4887ea33c96b/services/mailer/mailer.go#L216 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.
Author
Owner

@DeveloperOl commented on GitHub (Dec 19, 2019):

@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.

@DeveloperOl commented on GitHub (Dec 19, 2019): @zeripath using "dummy" as MAILER_TYPE results in the expected result: ```2019/12/19 11:51:36 ...ces/mailer/mailer.go:256:Send() [I] Mail From: noreply@gitea.[mydomain].io To: [[anonymized]@gmail.com] Body: Mime-Version: 1.0\01503d 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.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#4495