Solved

how to attach files to mails

Posted on 1998-08-25
9
248 Views
Last Modified: 2010-04-21
I use sendmail to send reports to mails generated
by a C program; now I want to join attachments to
those mails but it is very hard to find informations
about sending attachments;
I need infos about the header of the mail (mime version
content type,...), about the mime coding method (we
have the mimencode prg on our server), and about the
way Eudora and others are able to decode those attachments.
I would like strong technical answers to quote you;
that's why I could give a lot of points.
TIA.
0
Comment
Question by:bruyere
9 Comments
 
LVL 2

Expert Comment

by:JYoungman
ID: 2006778
It may be easier just to concatenate the output of a series
of calls to uuencode(1).

0
 

Author Comment

by:bruyere
ID: 2006779
I was told that uuencode cuts the attachment in 64K blocs,
that's why I prefer mime encoding.
I need that the user only has to click on a link in his
message to open the attached document (a pic, a textfile
from Unix to Dos or Windows...).
I managed to do it with uuencode but I had some trouble;
Eudora didn't decode it, and I had to make some more job,
and I would like to avoid it.
0
 
LVL 1

Expert Comment

by:TSchock
ID: 2006780
It's a standard functionality of sendmail to send files ...
try "man sendmail" on a Solaris System
0
 

Author Comment

by:bruyere
ID: 2006781
It was the first thing I did;
but there was no information about the way to attach a file.
I am now reading the MIME RFC1521 file to discover
element to build mails with attachments.

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 51

Expert Comment

by:ahoffmann
ID: 2006782
sendmail itself cannot make attachements ;-(

The easyest way (I know:) is to use a perl script:

#! /usr/local/bin/perl
$msg = new MIME::Lite
  From     => 'me',
  To       => 'you',
  Subject  => "don't miss it";
attach $msg
  Type     => 'TEXT',
  Data     => 'Your text here';
attach $msg
  Encoding => 'base64',
  Path     => '/path/to/file/to/be/attached';
$msg->send;


You may generate this file on the fly by your C-code and call it
via system(), exec(), or whatever.
0
 

Author Comment

by:bruyere
ID: 2006783
The Hoffmann's comment is exactly the answer I need;
Before I give you the points, do you know some books
where I could find clear and concise informations about
structure of mails with examples and so on.  Books
available in my country aren't enough dedicated.
I will have to learn perl to apply your script; I already
have found the MIME library.
Many thanks.

0
 

Expert Comment

by:izar
ID: 2006784
Check the MIME RFCs (www.internic.net, among others) and the
implementation of mime packages like the one inside MHS (available from any good unix ftp site near you).


0
 

Author Comment

by:bruyere
ID: 2006785
I got the sources at www.perl.org;
it is already loaded and it runs, with some changes instead;
now analysing the output I managed to have it running in
a C program without encoding with a very short subprogram.
I would like to give the points to Mr Hoffmann to close the question.
0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 400 total points
ID: 2006786
Best source for mail structure are the RFCs (see izar's comment),
I don't know of any good book about that :(

If you need more info about this question, feel free to ask.
If your questions are more about the secrets of perl, I suggest
to post them at the perl topic, to get answers from the gurus
there (which are probably faster/better than mine;-))
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now