-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a stringify method to the Policy class (#253)
- Loading branch information
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,19 @@ sub parse { | |
return bless \%policy, ref $self; # inherited defaults + overrides | ||
} | ||
|
||
sub stringify { | ||
my $self = shift; | ||
|
||
my %dmarc_record = %{$self}; | ||
delete $dmarc_record{domain}; | ||
|
||
my $dmarc_txt = 'v=' . (delete $dmarc_record{v}); # "v" tag must be first | ||
foreach my $key ( keys %dmarc_record ) { | ||
$dmarc_txt .= "; $key=$dmarc_record{$key}"; | ||
} | ||
return $dmarc_txt; | ||
} | ||
|
||
sub apply_defaults { | ||
my $self = shift; | ||
|
||
|
@@ -269,6 +282,13 @@ via DNS. | |
$pol->parse( 'v=DMARC1; p=none; rua=mailto:[email protected]' ); | ||
$pol->parse( 'v=DMARC1' ); # external reporting record | ||
=head2 stringify | ||
Returns the textual representation of the DMARC record. | ||
my $pol = Mail::DMARC::Policy->new('v=DMARC1; p=none;'); | ||
print $pol->stringify; | ||
=head1 Record Tags | ||
=head2 Tag Overview | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters