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

Error sending recovery link via Mail von Display Name has "," in it #9996

Closed
d-schiffner opened this issue Jun 5, 2024 · 1 comment · Fixed by #9999
Closed

Error sending recovery link via Mail von Display Name has "," in it #9996

d-schiffner opened this issue Jun 5, 2024 · 1 comment · Fixed by #9999

Comments

@d-schiffner
Copy link
Contributor

Describe the bug
Trying to send a password recovery mail to a user. The django mailer seems to only expect plain emails, but gets fully qualified ones instead.

To Reproduce
Steps to reproduce the behavior:

  1. User clicks on password-recovery / Go into admin overview -> click "Email recovery"
  2. Go to Logs
  3. See error

Expected behavior
The mail is being sent successfully

Logs

Stacktrace from authentik
Traceback (most recent call last):
  File "/ak-root/venv/lib/python3.12/site-packages/celery/app/trace.py", line 453, in trace_task
    R = retval = fun(*args, **kwargs)
                 ^^^^^^^^^^^^^^^^^^^^
  File "/ak-root/venv/lib/python3.12/site-packages/celery/app/trace.py", line 736, in __protected_call__
    return self.run(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ak-root/venv/lib/python3.12/site-packages/celery/app/autoretry.py", line 38, in run
    return task._orig_run(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/authentik/stages/email/tasks.py", line 89, in send_mail
    backend.send_messages([message_object])
  File "/ak-root/venv/lib/python3.12/site-packages/django/core/mail/backends/smtp.py", line 136, in send_messages
    sent = self._send(message)
           ^^^^^^^^^^^^^^^^^^^
  File "/ak-root/venv/lib/python3.12/site-packages/django/core/mail/backends/smtp.py", line 151, in _send
    sanitize_address(addr, encoding) for addr in email_message.recipients()
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ak-root/venv/lib/python3.12/site-packages/django/core/mail/message.py", line 92, in sanitize_address
    raise ValueError(
builtins.ValueError: Invalid address; only <surname> could be parsed from "<surname>, <givenname> <[email protected]>"

Version and Deployment (please complete the following information):

  • authentik version: 2024.4.2
  • Deployment: [e.g. docker-compose, helm]
@d-schiffner d-schiffner changed the title Error sending recovery link via Mail von Display Name has , in it Error sending recovery link via Mail von Display Name has "," in it Jun 5, 2024
@d-schiffner
Copy link
Contributor Author

I shortly checked with python3.12:

>>> parser.get_mailbox('Surname, Givenname <[email protected]>')
(Mailbox([AddrSpec([LocalPart([DotAtom([DotAtomText([ValueTerminal('Surname')])])])])]), ', Givenname <[email protected]>')
>>> parser.get_mailbox('"Surname, Givenname" <[email protected]>')
(Mailbox([NameAddr([DisplayName([QuotedString([BareQuotedString([ValueTerminal('Surname,'), WhiteSpaceTerminal(' '), ValueTerminal('Givenname')]), CFWSList([WhiteSpaceTerminal(' ')])])]), AngleAddr([ValueTerminal('<'), AddrSpec([LocalPart([DotAtom([DotAtomText([ValueTerminal('mailbox')])])]), ValueTerminal('@'), Domain([DotAtom([DotAtomText([ValueTerminal('mail'), ValueTerminal('.'), ValueTerminal('com')])])])]), ValueTerminal('>')])])]), '')

I found the source here:

https://github.com/goauthentik/authentik/blob/main/authentik/stages/email/utils.py#L37

If source line is replaced with the according quotes, the problem should be fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant