SUMMARY: dtmail and .signature files

From: Rick Schieche (scud@lewis-deh2.army.mil)
Date: Thu Jan 30 1997 - 09:59:57 CST


#include <cheesy_emotion.h>

This list is a ray of sunshine on an otherwise cloudy day...

Credit to Viet Hoang from Lucent Technologies.

Some people asked for a copy of that perl script for mailtool that I
mentioned. I will add it to the end of this message.

Thanks a lot!

Rick

---
Original Question:

Does anyone have any perl scripts or workarounds for automatically attaching a signature file to messages when using the CDE mailtool? I have a nifty perl script that works with mailtool, but doesn't seem to work with the dtmail program.

Answer:

No need, just create your .signature then edit your .mailrc and add

set signature='/x/y/.signature'

Viet Hoang Lucent Technologies/IBM-GS vhoang@lucent.com

----

Here is perl.signmail. Just edit .mailrc and add (or modify) this line:

set sendmail=/usr/local/bin/perl.signmail <--- or wherever you put it.

#!/usr/local/bin/perl # # What Goes On Here # # At the very simplest, this program accepts data on STDIN from MailTool, # appends the user's $HOME/.signature file to the stream, and pipes the # whole mess to sendmail. # # However, enclosures are a sticky point. Therefore, the program must # not simply append the signature, but must determine where it should # append the signature without corrupting any enclosures in the message. # # If a person sends a message and adds an enclosure(s), the signature is # appended into the main message body (which is, actually, the first enclosure # in the message.) If the sender sends an enclosure without any message # body, the program detects this and simply creates an additional enclosure # for the signature file. It seems to work. # # To activate this program via mailtool, add the following line to your # .mailrc file: # # set sendmail=/path/to/signmail # # Copyright (c) 1994 Clay Luther. August 1994. # clay@inetinc.com # This software is protected under the GNU Software License Agreement. #

$VERSION="1.1";

# HISTORY # Version 1.0 # Version 1.1 - fixed to work with perl5; fixed tainted variable problem

$SIGFILE = $ENV{'HOME'} . "/.signature"; # ^^^^^^^^^^^ at least that's where most are

$LF = "\n"; $HERALDENCLOSURE = 0; $FOUNDMAINTEXT = 0; $MARKER = "----------"; $HEADERS = 1; $SIGNATUREPRINTED = 0;

$ARGUMENTS = join(' ', @ARGV);

$LINES = &sigLines();

# Setup the environment $ENV{'PATH'} = ''; # '/bin:/usr/bin'; $ENV{'SHELL'} = '/bin/sh'; $ENV{'IFS'} = '' if $ENV{'IFS'} ne ''; @INC = $INC[$#INC - 1]; die "Perl library is writable by world!!!\n" if $< && -W $INC[0]; umask(077);

# Untaint the arguments $ARGUMENTS =~ /^([\w.]*)$/; $ARGUMENTS = $1;

open(MAIL, "| /usr/lib/sendmail -oi -t $ARGUMENTS") || die "can't fork: $!\n";

while (<STDIN>) { $SAVE_ = $_; if ($HEADERS) { if (/^Content-Type:\s*X-sun-attachment/) { $HERALDENCLOSURE = 1; } if (/^\n/) { print MAIL "X-Signmail: $VERSION. A Mailtool extension by Clay Luther.\n"; $HEADERS = 0; } } else { if ($HERALDENCLOSURE) { if (/^X-Sun-Data-Name: text/) { $FOUNDMAINTEXT = 1 if (!$FOUNDMAINTEXT); } elsif (/^$MARKER/) { if ($FOUNDMAINTEXT) { $HERALDENCLOSURE = 0; &printSignature(); } } elsif (/^X-Sun-Content-Lines:/) { if ($FOUNDMAINTEXT && $HERALDENCLOSURE) { m/^X-Sun-Content-Lines:\s(\d*)/; if ($1) { local($tlines) = $1 + $LINES + 2; $SAVE_ = "X-Sun-Content-Lines: $tlines\n"; } } } } } print MAIL $SAVE_; }

if (!$SIGNATUREPRINTED) { &printSignature(); }

close(MAIL) || die "pipe exited $?\n";

exit 0;

##########

sub printSignature { if (-r $SIGFILE) { if (open(SIGNATURE, "<$SIGFILE")) { if ($HERALDENCLOSURE) { print MAIL $LF . $MARKER . $LF; print MAIL "X-Sun-Data-Type: text\n"; print MAIL "X-Sun-Data-Description: text\n"; print MAIL "X-Sun-Data-Name: signature\n"; print MAIL "X-Sun-Charset: us-ascii\n"; print MAIL "X-Sun-Content-Lines: $LINES\n\n"; } else { print MAIL "\n\n"; } while (<SIGNATURE>) { print MAIL $_; } } close(SIGNATURE); } $SIGNATUREPRINTED = 1; }

sub sigLines { if (! -r $SIGFILE) { return 0; } open(SF,"<$SIGFILE") || return 0; local($cnt) = 0; while (<SF>) { $cnt++; } close(SF); return $cnt; }



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:11:44 CDT