45 |
$self->{option}->{value_type}->{per_message} = ['Message::Header',{ |
$self->{option}->{value_type}->{per_message} = ['Message::Header',{ |
46 |
-format => 'message-delivery-status-per-message', |
-format => 'message-delivery-status-per-message', |
47 |
-ns_default_phuri => $Message::Header::Message::DeliveryStatus::OPTION{namespace_uri}, |
-ns_default_phuri => $Message::Header::Message::DeliveryStatus::OPTION{namespace_uri}, |
48 |
|
-hook_init_fill_options => \&_fill_init_pm, |
49 |
|
-hook_stringify_fill_fields => \&_fill_fields_pm, |
50 |
}]; |
}]; |
51 |
$self->{option}->{value_type}->{per_recipient} = ['Message::Header',{ |
$self->{option}->{value_type}->{per_recipient} = ['Message::Header',{ |
52 |
-format => 'message-delivery-status-per-recipient', |
-format => 'message-delivery-status-per-recipient', |
53 |
-ns_default_phuri => $Message::Header::Message::DeliveryStatus::OPTION{namespace_uri}, |
-ns_default_phuri => $Message::Header::Message::DeliveryStatus::OPTION{namespace_uri}, |
54 |
|
-hook_init_fill_options => \&_fill_init_pr, |
55 |
|
-hook_stringify_fill_fields => \&_fill_fields_pr, |
56 |
}]; |
}]; |
57 |
} |
} |
58 |
|
|
182 |
my %o = @_; my %option = %{$self->{option}}; |
my %o = @_; my %option = %{$self->{option}}; |
183 |
for (grep {/^-/} keys %o) {$option{substr ($_, 1)} = $o{$_}} |
for (grep {/^-/} keys %o) {$option{substr ($_, 1)} = $o{$_}} |
184 |
$self->_delete_empty; |
$self->_delete_empty; |
185 |
|
$self->add ({-parse => 1}, '') unless $#{ $self->{value} } + 1; |
186 |
join ("\x0D\x0A", $self->{per_message}, @{ $self->{value} }) . "\x0D\x0A"; |
join ("\x0D\x0A", $self->{per_message}, @{ $self->{value} }) . "\x0D\x0A"; |
187 |
} |
} |
188 |
*as_string = \&stringify; |
*as_string = \&stringify; |
189 |
|
|
190 |
|
sub _fill_init_pm ($\%) { |
191 |
|
my ($hdr, $option) = @_; |
192 |
|
unless (defined $option->{fill_reporting_mta}) { |
193 |
|
$option->{fill_reporting_mta} = 1; |
194 |
|
$option->{fill_reporting_mta_name} = 'reporting-mta'; |
195 |
|
} |
196 |
|
} |
197 |
|
sub _fill_init_pr ($\%) { |
198 |
|
my ($hdr, $option) = @_; |
199 |
|
unless (defined $option->{fill_action}) { |
200 |
|
$option->{fill_action} = 1; |
201 |
|
} |
202 |
|
unless (defined $option->{fill_final_recipient}) { |
203 |
|
$option->{fill_final_recipient} = 1; |
204 |
|
} |
205 |
|
unless (defined $option->{fill_status}) { |
206 |
|
$option->{fill_status} = 1; |
207 |
|
} |
208 |
|
} |
209 |
|
|
210 |
|
sub _fill_fields_pm ($\%\%) { |
211 |
|
my ($hdr, $exist, $option) = @_; |
212 |
|
my $ns = ':'.$option->{ns_default_phuri}; |
213 |
|
if ($option->{fill_reporting_mta} |
214 |
|
&& !$exist->{ $option->{fill_reporting_mta_name}.$ns }) { |
215 |
|
my $rmta = $hdr->field ($option->{fill_reporting_mta_name}); |
216 |
|
$rmta->type ('dns'); |
217 |
|
$rmta->value ('localhost'); |
218 |
|
} |
219 |
|
} |
220 |
|
sub _fill_fields_pr ($\%\%) { |
221 |
|
my ($hdr, $exist, $option) = @_; |
222 |
|
my $ns = ':'.$option->{ns_default_phuri}; |
223 |
|
if ($option->{fill_action} && !$exist->{ 'action'.$ns }) { |
224 |
|
my $act = $hdr->field ('action'); |
225 |
|
$act->value ('failed'); |
226 |
|
} |
227 |
|
if ($option->{fill_final_recipient} && !$exist->{ 'final-recipient'.$ns }) { |
228 |
|
my $fr = $hdr->field ('final-recipient'); |
229 |
|
$fr->type ('rfc822'); |
230 |
|
$fr->value ('foo@bar.invalid'); |
231 |
|
} |
232 |
|
if ($option->{fill_status} && !$exist->{ 'status'.$ns }) { |
233 |
|
my $fr = $hdr->add (status => '4.0.0'); |
234 |
|
} |
235 |
|
} |
236 |
|
|
237 |
## Inherited: option, clone |
## Inherited: option, clone |
238 |
|
|
239 |
## $self->_option_recursive (\%argv) |
## $self->_option_recursive (\%argv) |