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

Allow system users to send mails from IPv6 localhost. #1710

Merged
merged 1 commit into from
Sep 7, 2023

Conversation

orhtej2
Copy link
Contributor

@orhtej2 orhtej2 commented Sep 7, 2023

The problem

As observed in FitTrackee system user was not able to send mail. I narrowed it down to the following stanza(s)

manifest.toml:

[resources]
    [resources.system_user]
    allow_email = true

sample.py:

import smtplib
import ssl

sender_email = "[email protected]"
username = "system_user"
password = "password"
host = "domain.tld"
port = 25
recipient = "[email protected]"

message = "From: %s\r\nTo: %s\r\n\r\nTest message" % (sender_email, recipient)

print(message)

connection_params = {}
context = ssl.create_default_context()

with smtplib.SMTP(
  host, port, **connection_params
) as smtp:
  smtp.set_debuglevel(2)
  smtp.ehlo()
  smtp.starttls(context=context)
  smtp.ehlo()
  smtp.login(username, password)
  smtp.sendmail(sender_email, recipient, message)
  smtp.quit()

journalctl would indicate SMTP AUTH error for connection coming from localhost[::1].

Solution

As per documentation on allow_nets dovecot password file property one should add IPv6's localhost aka ::1 as well as local to allowed domains to allow connections in IPv6 environment as well as auth in no-IP scenarios (whatever these are).

PR Status

This is the piece of code that powers yunohost tools regen-conf, right?

Resulting change tested, hopefully it generates dovecot configuration as expected.

How to test

Relevant Python stanza provided, test with any provisioned system user with e-mail capabilities.

@orhtej2
Copy link
Contributor Author

orhtej2 commented Sep 7, 2023

(Python code heavily inspired by FitTrackee's e-mail system: https://github.com/SamR1/FitTrackee/blob/master/fittrackee/emails/email.py)

@alexAubin alexAubin merged commit ec6bf12 into YunoHost:dev Sep 7, 2023
2 checks passed
@Thovi98
Copy link
Contributor

Thovi98 commented Sep 8, 2023

Thank you @orhtej2 for your help and the fix 🎉

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 this pull request may close these issues.

3 participants