Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions conf/postfix/main.cf
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
smtp_address_preference = ipv6

#### Fit to the maximum message size to 25mb, more than allowed by GMail or Yahoo ####
# /!\ This size is the size of the attachment in base64.
Expand Down
3 changes: 3 additions & 0 deletions hooks/conf_regen/19-postfix
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ do_pre_regen() {
sed -i \
's/inet_interfaces = all/&\ninet_protocols = ipv4/' \
"${postfix_dir}/main.cf"
sed -i \
's/smtp_address_preference = ipv6/smtp_address_preference = ipv4/' \
"${postfix_dir}/main.cf"
fi
}

Expand Down
10 changes: 9 additions & 1 deletion src/dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,15 @@ def _build_dns_conf(
mail.append((basename, ttl, "MX", f"10 {domain}."))

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.

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"'))
Comment on lines +211 to +219

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 on lines +211 to +219

@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"'))


# DKIM/DMARC record
dkim_host, dkim_publickey = _get_DKIM(domain)
Expand Down
Loading