[ic] email-raw usertag broken for Net::SMTP FIX

Peter peter at pajamian.dhs.org
Fri Apr 29 18:49:19 EDT 2005


Well technically it's not broken because it does specify in the docs 
that it uses sendmail.  But if you use Net::SMTP for sending out emails 
then no emails will be sent via this tag.  I've modified the tag to work 
with Net::SMTP as well (feel free to tweak and change or whatever) and 
would like to submit this to be included in future versions of 
interchange.  Here's a patch to IC 5.2.

Note that in theory you could eliminate all bbut the middle clause to 
the if/elsif/else statement, but i wanted to keep the original 
functionality of being able to send directly to sendmail rather than 
simulate it through the send_mail function.

Note the following patch may (probably does) suffer from word-wrap:

--- email_raw.tag.orig  Wed May  5 06:53:36 2004
+++ email_raw.tag       Fri Apr 29 15:33:57 2005
@@ -30,12 +30,25 @@
      $body =~ s/^\s+//;

      SEND: {
-        open(Vend::MAIL,"|$Vend::Cfg->{SendMailProgram} -t") or last SEND;
-        print Vend::MAIL $body
-            or last SEND;
-        close Vend::MAIL
-            or last SEND;
-        $ok = ($? == 0);
+        my $using = $Vend::Cfg->{SendMailProgram};
+
+        if (lc $using eq 'none') {
+               $ok = 1;
+               last SEND;
+       } elsif (lc $using eq 'net::smtp') {
+               $body =~ s/^(.+?)(?:\r?\n){2}//s;
+               my $headers = $1;
+               last SEND unless $headers;
+               my @head = split(/\r?\n/,$headers);
+               $ok = send_mail(\@head,$body);
+       } else {
+               open(Vend::MAIL,"|$using -t") or last SEND;
+               print Vend::MAIL $body
+                   or last SEND;
+               close Vend::MAIL
+                   or last SEND;
+               $ok = ($? == 0);
+       }
      }

      if (!$ok) {


More information about the interchange-users mailing list