diff -urN ../swaks-20130209.0.orig/swaks ./swaks --- ../swaks-20130209.0.orig/swaks 2014-10-26 13:38:56.000000000 +0200 +++ ./swaks 2014-12-01 00:50:39.000000000 +0200 @@ -74,7 +74,7 @@ # XXX hash that we can pass verbatim here open_link(); -sendmail($opts->{from}, $opts->{to}, $opts->{helo}, $opts->{data}, +sendmail($opts->{from}, $opts->{from_size}, $opts->{from_envid}, $opts->{to}, $opts->{to_notify}, $opts->{to_orcpt}, $opts->{helo}, $opts->{data}, $opts->{a_user}, $opts->{a_pass}, $opts->{a_type}); teardown_link(); @@ -171,7 +171,11 @@ sub sendmail { my $from = shift; # envelope-from + my $from_size = shift; # envelope-from size parameter + my $from_envid = shift; # envelope-from envid parameter my $to = shift; # envelope-to + my $to_notify = shift; # envelope-to notify parameter + my $to_orcpt = shift; # envelope-to notify parameter my $helo = shift; # who am I? my $data = shift; # body of message (content after DATA command) my $a_user = shift; # what user to auth with? @@ -299,13 +303,13 @@ do_smtp_quit(1, 0) if ($G::quit_after eq 'auth'); # send MAIL - do_smtp_mail($from); # failures in this handled by smtp_mail_callback + do_smtp_mail($from, $from_size, $from_envid); # failures in this handled by smtp_mail_callback # QUIT here if the user has asked us to do so do_smtp_quit(1, 0) if ($G::quit_after eq 'mail'); # send RCPT (sub handles multiple, comma-delimited recips - do_smtp_rcpt($to); # failures in this handled by smtp_rcpt_callback + do_smtp_rcpt($to, $to_notify, $to_orcpt); # failures in this handled by smtp_rcpt_callback # note that smtp_rcpt_callback increments # $G::smtp_rcpt_failures at every failure. This and # $G::smtp_rcpt_total are used after DATA for LMTP @@ -861,8 +865,10 @@ sub do_smtp_mail { my $m = shift; # from address + my $mail_from_size = shift; # from size parameter + my $mail_from_envid = shift; # from envid parameter - transact(cxn_string => "MAIL FROM:<$m>", expect => '250', defer => 1, fail_callback => \&smtp_mail_callback); + transact(cxn_string => "MAIL FROM:<$m>".($mail_from_size ? " SIZE=$mail_from_size" : "").($mail_from_envid ? " ENVID=$mail_from_envid" : ""), expect => '250', defer => 1, fail_callback => \&smtp_mail_callback); return(1); # the callback handles failures, so just return here } @@ -875,12 +881,16 @@ sub do_smtp_rcpt { my $m = shift; # string of comma separated recipients + my $rcpt_to_notify = shift; # to notify parameter + my $rcpt_to_orcpt = shift; # to orcpt parameter my $f = 0; # The number of failures we've experienced my @a = split(/,/, $m); + my @orcpt = split(/,/, $rcpt_to_orcpt); $G::smtp_rcpt_total = scalar(@a); foreach my $addr (@a) { - transact(cxn_string => "RCPT TO:<$addr>", expect => '250', defer => 1, + my $orcpt_addr = shift(@orcpt); + transact(cxn_string => "RCPT TO:<$addr>".($rcpt_to_notify ? " NOTIFY=$rcpt_to_notify" : "").($orcpt_addr ? " ORCPT=$orcpt_addr" : ""), expect => '250', defer => 1, fail_callback => \&smtp_rcpt_callback); } @@ -1412,9 +1422,21 @@ # envelope-(f)rom address { opts => ['f', 'from'], suffix => ':s', okey => 'mail_from', type => 'scalar', }, + # envelope-from size parameter + { opts => ['from-size'], suffix => ':s', + okey => 'from_size', type => 'scalar', }, + # envelope-from envid parameter + { opts => ['from-envid'], suffix => ':s', + okey => 'from_envid', type => 'scalar', }, # envelope-(t)o address { opts => ['t', 'to'], suffix => ':s', okey => 'mail_to', type => 'scalar', }, + # envelope-to address notify parameter + { opts => ['to-notify'], suffix => ':s', + okey => 'to_notify', type => 'scalar', }, + # envelope-to address orcpt parameter + { opts => ['to-orcpt'], suffix => ':s', + okey => 'to_orcpt', type => 'scalar', }, # (h)elo string { opts => ['h', 'helo', 'ehlo', 'lhlo'], suffix => ':s', okey => 'mail_helo', type => 'scalar', }, @@ -2013,6 +2035,10 @@ ? "$user\@$hostname" : interact("From: ", '^.*$')); $n{from} = '' if ($n{from} eq '<>'); + $n{from_size} = $o->{from_size} if ($o->{from_size}); + $n{from_envid} = $o->{from_envid} if ($o->{from_envid}); + $n{to_notify} = $o->{to_notify} if ($o->{to_notify}); + $n{to_orcpt} = $o->{to_orcpt} if ($o->{to_orcpt}); # local interface to connect from $G::link{lint} = $o->{lint} || interact("Interface: ", '^.*$')