Solved

how to attach files to mails

Posted on 1998-08-25
9
227 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

762 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

24 Experts available now in Live!

Get 1:1 Help Now