Skip to content

fix : Ipv6 pref sending if available - #2312

Open
frju365 wants to merge 6 commits into
YunoHost:devfrom
Nerteron:fix-2465-ipv6-pref-sending-if-available
Open

fix : Ipv6 pref sending if available#2312
frju365 wants to merge 6 commits into
YunoHost:devfrom
Nerteron:fix-2465-ipv6-pref-sending-if-available

Conversation

@frju365

@frju365 frju365 commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

AW: I just added the solution provided by @jershon

The problem

For SPF record :
As I understood, it could be problem if main domain (exemple for a website) has different ipv4 than actual mail server.

For ipv6 :
Some email provider communicate only in ipv6. Apparently following issue this can be a solution of not receiving mail on some email hosting providers.

Related issues: : fixes YunoHost/issues#2465
Related PRs:

Solution

  • add preference to ipv6 if avilable
  • Correct SPF record. Allow domain to be handle by server IP even if main site is no handle by server.

AI transparency: Understand difference between record (I didn't fully remember what was the good way to handle such case).

PR Status

Tested partially

Code TODOs

Here are frequently forgotten tasks:

  • Discuss about this change with others contributors (on chat, contributors meeting, forum, issues or pr)
  • Update related repo (like yunohost-admin, yunohost-portal, package-linter, etc.)
  • Write data or settings migration
  • Pass Continuous Integration checks
    • Add some missing translations keys
    • Update/write unit tests
  • Update/write documentation

Tests TODOs

Indicate here tests you have already done, and tests you think should be done

  • Run the code in cli by calling command by hand
  • Test change on configuration on an instance

How to test

Please add here commands to install dependencies, manual change to do in ynh-dev container, commands to make some basic tests, etc.
...

@frju365
frju365 marked this pull request as draft June 20, 2026 18:29
@frju365
frju365 marked this pull request as ready for review June 20, 2026 20:57
@frju365 frju365 changed the title [DRAFT] Ipv6 pref sending if available Issue 2465 : Ipv6 pref sending if available Jun 20, 2026
@frju365 frju365 changed the title Issue 2465 : Ipv6 pref sending if available fix : Ipv6 pref sending if available Jun 21, 2026
Comment thread src/dns.py
if settings["mail_out"]:
mail.append((basename, ttl, "TXT", '"v=spf1 a mx -all"'))
# Tentative de mitigation en cas où le serveur du domaine d'envoi du mail est différent
# du serveur du domaine (site externalisé) Issue: #2465

@zamentur zamentur Jul 23, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue 2465 seems not about distinct mail and web server for a same domain.

Comment thread src/dns.py
Comment on lines +211 to +219
# Tentative de mitigation en cas où le serveur du domaine d'envoi du mail est différent
# du serveur du domaine (site externalisé) Issue: #2465
spf4 = ""
spf6 = ""
if ipv4:
spf4 = ' ip4:' + ipv4
if ipv6:
spf6 = ' ip6:' + ipv6
mail.append((basename, ttl, "TXT", f'"v=spf1 a mx{spf4}{spf6} -all"'))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a already means AAAA if the mail is sent with ipv6.

SO for me the only reasons to add this, is the case where no MX or A records exists for the IP of the server. This happens if mail_in is disabled and if a website is hosted on the domain on another host.

https://github.com/Nerteron/yunohost/blob/12c2594b1024a604d5bd3d96007b79905d4de87d/src/dns.py#L207

I think there could be a lot of situations for which SPF should be customized, the important thing is to check with diagnosis that current IPs are allowed.

For me this part should be in another PR , maybe with a settings to include a custom part to SPF

Comment thread src/dns.py
Comment on lines +211 to +219
# Tentative de mitigation en cas où le serveur du domaine d'envoi du mail est différent
# du serveur du domaine (site externalisé) Issue: #2465
spf4 = ""
spf6 = ""
if ipv4:
spf4 = ' ip4:' + ipv4
if ipv6:
spf6 = ' ip6:' + ipv6
mail.append((basename, ttl, "TXT", f'"v=spf1 a mx{spf4}{spf6} -all"'))

@zamentur zamentur Jul 23, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Tentative de mitigation en cas où le serveur du domaine d'envoi du mail est différent
# du serveur du domaine (site externalisé) Issue: #2465
spf4 = ""
spf6 = ""
if ipv4:
spf4 = ' ip4:' + ipv4
if ipv6:
spf6 = ' ip6:' + ipv6
mail.append((basename, ttl, "TXT", f'"v=spf1 a mx{spf4}{spf6} -all"'))
mail.append((basename, ttl, "TXT", '"v=spf1 a mx -all"'))

@zamentur zamentur added the bugfix This PR fix one or several bug label Jul 23, 2026

@zamentur zamentur left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to remove the SPF part

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix This PR fix one or several bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Configuration of IPv6 for email sending

2 participants