[NTLUG:Discuss] OT attachments to email

Chris Cox cjcox at acm.org
Thu Aug 4 17:56:57 CDT 2005


Fred James wrote:
> All
> This a bit off topic, but it does start with Unix.  The question first,
> and then the details for those who are interested.
> 
> Question:
> From a Unix system, I need to send script generated email to a list of
> addresses with an attachment.  The recipients are a mixed bag - PC and
> MAC users, and some use Notes as their mail client.  As detailed below,
> the result for some MAC/Notes user is less than satisfactory when I use
> 'uuencode'.  Can anyone suggest another route, or some documentation,
> please?  Or is this just a hopeless case of non-interoperability?

It's pretty rotten.. I like metasend... but even then I usually
post process the output and clean things up a bit to add things
like "Content-Disposition: attachment; filename="whatever"

I think metasend gets you mostly there.

For example:

metasend -b -F me at myhouse.com \
-s 'Test Message' \
-m text/plain \
-f mymessage.txt \
-n \
-m application/pdf \
-o savethisforlater.txt \
-f mypdffile.pdf \
-t whoever at wherever.com,whatever at whoever.com

Now that creates a message in savethisforlater.txt that
can be sent via a /usr/lib/sendmail -t

However, it doesn't quite have enough umphf... so I
post process savethisforlater.txt...

awk '
/Content-type:/ {pdf=0;}
/Content-type: application.pdf/ {pdf=1;}
/base64/ {
  if (pdf) {
     print;
     print "Content-Disposition: attachment; filename=\"mypdffile.pdf\""
     next;
  }
}
{print;}' savethisforlater.txt | /usr/lib/sendmail -t

In your case, instead of a pdf, you'd have some kind of mime
info for word (application/ms-word ???)... I don't know.. too
many mime types that mean the same thing.

I wish metasend just had a few more features... sigh...

I've looked at many, many tools... this is the one that worked
for me.  I'll gladly drop it for a "good" tool.





More information about the Discuss mailing list