go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
45.03k stars 5.49k forks source link

Accented letters are not accepted in mailer.FROM #2188

Closed edgar-bonet closed 5 years ago

edgar-bonet commented 7 years ago

Description

I tried to activate gitea's mailer by putting the following in custom/conf/app.ini:

[mailer]
ENABLED      = true
FROM         = Néel Institut git hosting service <git@***>
USE_SENDMAIL = true

When I clicked on the "Send Test Email" button, I got the error message: Impossible d'envoyer un e-mail de test à 'bonet@grenoble.cnrs.fr': gomail: could not send email 1: gomail: invalid address "=?UTF-8?q?N=C3=A9el_Institut_git_hosting_service_?=": mail: unclosed angle-addr.

I then replaced "Néel" by "Neel" and everything worked fine, thus I assume this is a problem with gitea (or gomail) mishandling the accented letter "é" (= U+00E9, Latin small letter e with acute).

It should be noted that "=?UTF-8?q?N=C3=A9el_Institut_git_hosting_service_?=" is the proper way to encode "Néel Institut git hosting service" in an e-mail header, as per RFC 2047. Thus, it looks like gomail genuinely attempts to support non-ASCII characters in the e-mail From field.

scr34m commented 7 years ago

This is a gomail problem, but there is a workaround, but this problem occurs too when user name contains any non ASCII character.

type mimeEncoder struct {
    mime.WordEncoder
}

bEncoding := mimeEncoder{mime.BEncoding}
name := bEncoding.Encode("utf-8", "József Galamb")

msg := NewMessageFrom([]string{name + " <jon@example.org>"}, "jon@example.org", "subject", "body")

If this solution is okay then i could create a PR:

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

stale[bot] commented 5 years ago

This issue has been automatically closed because of inactivity. You can re-open it if needed.

zeripath commented 5 years ago

This was fixed by #2559