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

ZMS-165 #42

Merged
merged 3 commits into from
Aug 8, 2024
Merged
Changes from 1 commit
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
12 changes: 11 additions & 1 deletion lib/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,24 @@ async function hookMail(plugin, connection, params) {
let spfResult;

try {
const isRemotePrivate = connection.remote.is_private;

spfResult = await checkSpf({
resolver: plugin.resolver,
ip: connection.remote.ip, // SMTP client IP
ip: isRemotePrivate ? undefined : connection.remote.ip, // SMTP client IP (undefined for if remote is private network)
helo: connection.hello?.host, // EHLO/HELO hostname
sender: txn.notes.sender, // MAIL FROM address
mta: connection.local?.host, // MX hostname
maxResolveCount: plugin.cfg?.auth?.dns?.maxLookups
});

if (isRemotePrivate) {
// given undefined client ip verification will by default return neutral SPF result, replace 'undefined' with the IP
spfResult.status.comment = spfResult.status.comment.replaceAll('undefined', connection.remote.ip);
spfResult.header = spfResult.header.replaceAll('undefined', connection.remote.ip);
spfResult.info = spfResult.header.replaceAll('undefined', connection.remote.ip);
}

txn.notes.spfResult = spfResult;
} catch (err) {
txn.notes.spfResult = { error: err };
Expand Down