Debian Codegraph @

plugins/dont_require_anglebrackets

raw
1 #!perl -w
2
3 =head1 NAME
4
5 dont_require_anglebrackets
6
7 =head1 SYNOPSIS
8
9 accept addresses in MAIL FROM:/RCPT TO: commands without surrounding <>
10
11 =head1 DESCRIPTION
12
13 RFC821 requires that email addresses presented during the SMTP conversation
14 be enclosed in angle brackets. Like this:
15
16 MAIL FROM:<[email protected]>
17
18 This plugin relaxes that requirement, accepting messages in this format:
19
20 MAIL FROM:[email protected]
21
22 =cut
23
24 sub hook_mail_pre {
25 my ($self, $transaction, $addr) = @_;
26 unless ($addr =~ /^<.*>$/) {
27 $addr = '<' . $addr . '>';
28 $self->adjust_karma(-2);
29 $self->log(LOGINFO, "fail, added MAIL angle brackets");
30 }
31 return (OK, $addr);
32 }
33
34 sub hook_rcpt_pre {
35 my ($self, $transaction, $addr) = @_;
36 unless ($addr =~ /^<.*>$/) {
37 $addr = '<' . $addr . '>';
38 $self->adjust_karma(-2);
39 $self->log(LOGINFO, "fail, added RCPT angle brackets");
40 }
41 return (OK, $addr);
42 }