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

create a synthetic mfrom when mfrom is empty #11

Merged
merged 1 commit into from
Jun 17, 2024
Merged
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
6 changes: 3 additions & 3 deletions bin/spfd
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,9 @@ and C<temperror>, respectively, in order to comply with RFC 4408 terminology.

=item *

SPF checks with an empty identity are no longer supported. In the case of an
empty C<MAIL FROM> SMTP transaction parameter, perform a check with the C<helo>
scope directly.
In the case of an empty C<MAIL FROM> SMTP transaction parameter (C<<
MAIL FROM:<> >>), the identity checked will be postmaster@helo name as specified
in RFC 7208.

=back

Expand Down
6 changes: 4 additions & 2 deletions bin/spfquery
Original file line number Diff line number Diff line change
Expand Up @@ -626,8 +626,10 @@ if (
exit(255);
}

if (defined($identity) and $identity eq '') {
STDERR->print("Error: Empty identities are not supported. See spfquery(1).\n");
if (defined($identity) and $identity eq '' and defined $helo_identity) {
$identity = 'postmaster@' . $helo_identity;
} elsif (defined($identity) and $identity eq '') {
STDERR->print("Error: Empty identities are not supported without specifying HELO.\n");
exit(255);
}

Expand Down
18 changes: 12 additions & 6 deletions lib/Mail/SPF/Request.pm
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ The given identity is the C<MAIL FROM> parameter of an SMTP transaction (RFC
the formal definition of the C<MAIL FROM> scope.

I<Note>: In the case of an empty C<MAIL FROM> SMTP transaction parameter (C<<
MAIL FROM:<> >>), you should perform a check with the C<helo> scope instead.
MAIL FROM:<> >>), the identity checked will be postmaster@helo name as specified
in RFC 7208.

=item B<'pra'>

Expand All @@ -175,9 +176,10 @@ I<Required>. A string denoting the sender identity whose authorization should
be checked. This is a domain name for the C<helo> scope, and an e-mail address
for the C<mfrom> and C<pra> scopes.

I<Note>: An empty identity must not be passed. In the case of an empty C<MAIL
FROM> SMTP transaction parameter, you should perform a check with the C<helo>
scope instead.
I<Note>: An empty identity should not be passed, in the case of an empty
C<MAIL FROM> SMTP transaction parameter (C<<MAIL FROM:<> >>),
the identity checked will be postmaster@helo name as specified
in RFC 7208.

=item B<ip_address>

Expand Down Expand Up @@ -256,8 +258,12 @@ sub new {
# Identity:
defined($self->{identity})
or throw Mail::SPF::EOptionRequired("Missing required 'identity' option");
length($self->{identity})
or throw Mail::SPF::EInvalidOptionValue("'identity' option must not be empty");
if(not length($self->{identity}) and (defined $self->{helo_identity})) {
# if identity is <>, try with postmaster@helo as specified in RFC 7208 section 2.4
$self->{identity} = 'postmaster@' . $self->{helo_identity};
} elsif(not length($self->{identity})) {
throw Mail::SPF::EInvalidOptionValue("'identity' option must not be empty without specifying HELO");
}

# Extract domain and localpart from identity:
if (
Expand Down