Subject: | Patch to use ESMTP return receipts |
G'day all,
This patch is to support ESMTP receipt requests such as
MAIL FROM: blah@foo RET=FULL
RCPT TO: foo@bar NOTIFY=SUCCESS,FAILURE,DELAY
activated via a new confirm value
diff -Naur Mail-Sender-0.8.10/Config new/Config
--- Mail-Sender-0.8.10/Config Thu Jan 1 10:00:00 1970
+++ new/Config Fri Mar 25 13:02:28 2005
@@ -0,0 +1 @@
+
diff -Naur Mail-Sender-0.8.10/Sender.pm new/Sender.pm
--- Mail-Sender-0.8.10/Sender.pm Mon Nov 24 07:14:22 2003
+++ new/Sender.pm Sun Apr 3 17:57:15 2005
@@ -651,8 +651,10 @@
C<>=> whether you request reading or delivery confirmations and to what addresses:
"delivery" - only delivery, to the C<from> address
+ "smtp_delivery" - only delivery, using the relevant smtp extensions (return delivery headers only), to the C<from> address
"reading" - only reading, to the C<from> address
"delivery, reading" - both confirmations, to the C<from> address
+ "smtp_delivery: full, reading" - both confirmations, to the C<from> address, return full message
"delivery: my.other@address.com" - only delivery, to my.other@address.com
...
@@ -1088,7 +1090,24 @@
return $s unless ref $s; # return the error number if we did not get a socket
$self->{'socket'} = $s;
- $_ = send_cmd $s, "mail from: <$self->{'fromaddr'}>";
+ my $notify_value = '';
+ my $ret_value = '';
+ if ($self->{'confirm'}) {
+ for my $confirm (split /\s*,\s*/, $self->{'confirm'}) {
+ if ($confirm =~ /^\s*reading\s*(?:\:\s*(.*))?/i) {
+ } elsif ($confirm =~ /^\s*delivery\s*(?:\:\s*(.*))?/i) {
+ } elsif ($confirm =~ /^\s*smtp_delivery\s*(?:\:\s*(.*))?/i) {
+ $notify_value = ' NOTIFY=SUCCESS,FAILURE,DELAY';
+ if ($1 =~ /full/i) {
+ $ret_value = ' RET=FULL';
+ } else {
+ $ret_value = ' RET=HDRS';
+ }
+ }
+ }
+ }
+
+ $_ = send_cmd $s, "mail from: <$self->{'fromaddr'}>$ret_value";
if (!/^[123]/) { return $self->Error(COMMERROR($_)); }
{ local $^W;
@@ -1097,9 +1116,9 @@
my %failed;
foreach my $addr ( @{$self->{'to_list'}}, @{$self->{'cc_list'}}, @{$self->{'bcc_list'}}) {
if ($addr =~ /<(.*)>/) {
- $_ = send_cmd $s, "rcpt to: <$1>";
+ $_ = send_cmd $s, "rcpt to: <$1>$notify_value";
} else {
- $_ = send_cmd $s, "rcpt to: <$addr>";
+ $_ = send_cmd $s, "rcpt to: <$addr>$notify_value";
}
if (!/^[123]/) {
chomp;
@@ -1117,9 +1136,9 @@
} else {
foreach my $addr ( @{$self->{'to_list'}}, @{$self->{'cc_list'}}, @{$self->{'bcc_list'}}) {
if ($addr =~ /<(.*)>/) {
- $_ = send_cmd $s, "rcpt to: <$1>";
+ $_ = send_cmd $s, "rcpt to: <$1>$notify_value";
} else {
- $_ = send_cmd $s, "rcpt to: <$addr>";
+ $_ = send_cmd $s, "rcpt to: <$addr>$notify_value";
}
if (!/^[123]/) { return $self->Error(USERUNKNOWN($addr, $self->{'smtp'})); }
}
@@ -1327,7 +1346,24 @@
return $s unless ref $s; # return the error number if we did not get a socket
$self->{'socket'} = $s;
- $_ = send_cmd $s, "mail from: <$self->{'fromaddr'}>";
+ my $notify_value = '';
+ my $ret_value = '';
+ if ($self->{'confirm'}) {
+ for my $confirm (split /\s*,\s*/, $self->{'confirm'}) {
+ if ($confirm =~ /^\s*reading\s*(?:\:\s*(.*))?/i) {
+ } elsif ($confirm =~ /^\s*delivery\s*(?:\:\s*(.*))?/i) {
+ } elsif ($confirm =~ /^\s*smtp_delivery\s*(?:\:\s*(.*))?/i) {
+ $notify_value = ' NOTIFY=SUCCESS,FAILURE,DELAY';
+ if ($1 =~ /full/i) {
+ $ret_value = ' RET=FULL';
+ } else {
+ $ret_value = ' RET=HDRS';
+ }
+ }
+ }
+ }
+
+ $_ = send_cmd $s, "mail from: <$self->{'fromaddr'}>$ret_value";
if (!/^[123]/) { return $self->Error(COMMERROR($_)); }
{ local $^W;
@@ -1336,9 +1372,9 @@
my %failed;
foreach my $addr ( @{$self->{'to_list'}}, @{$self->{'cc_list'}}, @{$self->{'bcc_list'}}) {
if ($addr =~ /<(.*)>/) {
- $_ = send_cmd $s, "rcpt to: <$1>";
+ $_ = send_cmd $s, "rcpt to: <$1>$notify_value";
} else {
- $_ = send_cmd $s, "rcpt to: <$addr>";
+ $_ = send_cmd $s, "rcpt to: <$addr>$notify_value";
}
if (!/^[123]/) {
s/^\d{3} //;
@@ -1355,9 +1391,9 @@
} else {
foreach my $addr ( @{$self->{'to_list'}}, @{$self->{'cc_list'}}, @{$self->{'bcc_list'}}) {
if ($addr =~ /<(.*)>/) {
- $_ = send_cmd $s, "rcpt to: <$1>";
+ $_ = send_cmd $s, "rcpt to: <$1>$notify_value";
} else {
- $_ = send_cmd $s, "rcpt to: <$addr>";
+ $_ = send_cmd $s, "rcpt to: <$addr>$notify_value";
}
if (!/^[123]/) {
return $self->Error(USERUNKNOWN($addr, $self->{'smtp'}));