• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 904
  • Last Modified:

uuencode and cat a file to an email

I want to cat a file to the body of an email and attach a uuencoded file but it's not working in Solaris 8.

Example

  uuencode file.xls attachethisfilename.xls > attachethisfilename.xls
  cat /thisfilewithinthemessagebody | mailx -s "subject line" $emailall < attachethisfilename.xls


Any sugestions?
0
jjc_mn
Asked:
jjc_mn
1 Solution
 
Gerwin Jansen, EE MVETopic Advisor Commented:
Hi jjc_mn, how about this:

( cat thisfilewithinthemessagebody; uuencode file.xls uuencode file.xls ) | mailx -s "subject line" $emailall
0
 
Dave BaldwinFixer of ProblemsCommented:
What does "it's not working" mean?  I think I see the problem.  Emails with attachments need MIME boundaries defined.  Just 'cat'ing it doesn't do that.  Look at the "View Source" in an email with an attachment and you can see what I'm talking about.  Basic info: http://en.wikipedia.org/wiki/E-mail_attachment   More technical details: http://en.wikipedia.org/wiki/MIME
0
 
farzanjCommented:
It should work both the ways given by jjc_mn and gerwinjansen
Take a look
http://www.shelldorado.com/articles/mailattachments.html

In my company a lot of scripts were sending email attachments this way.  But when there was an upgrade to the Exchange server, the server admins did not keep any regard for this kind of attachment and just for the common MIME encapsulation, as a result of which the email system broke.  So I had to write a Perl script to make a MIME thing because mutt was not installed or any other such command line clients

If you have mutt or can get mutt, then the there is no problem

echo "email " | mail -s "subject" -a attachment email@address
0
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
Dave BaldwinFixer of ProblemsCommented:
I ask because the 'attachment' process should uuencode the file and create the MIME boundaries and maybe doing the uuencode first is causing the problem, not solving it.
0
 
gheistCommented:
http://en.wikipedia.org/wiki/MIME#Multipart_messages (the example should be well explaining)

In 21st century you do not need to uuencode or base64 encode because 99,9% of mail servers were upgraded in last 10 years and are 8-bit clean, and will let your mail pass without any problem. I think sendmail is only dinosaur to do 8-7 bit conversion on the fly. (odds are high it is just lying around idle on your system)
0
 
Dave BaldwinFixer of ProblemsCommented:
I suggest that you look at the source of an email with an attached file, especially an image or PDF.  Virtually all mail clients use the MIME format and base64 encoding to include them in an email.  Images embedded in an email are done the same way.  MIME boundaries are also used to separate plain text and HTML parts of a message.
0
 
gheistCommented:
Base64 is better forgotten. it wastes space in the age of 8BITMIME capable mailers (I think relevant RFC was already there in 1995 when i started in IT)
0
 
jjc_mnAuthor Commented:
I had to  change it a little but it works great now. Thanks!.

( cat thisfilewithinthemessagebody; uuencode file.xls  file2.xls ) | mailx -s "subject line" $emailall
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now