[H-GEN] File Atachments With Sendmail

Anthony Towns aj at azure.humbug.org.au
Fri May 29 03:14:01 EDT 1998


On Fri, May 29, 1998 at 04:45:52PM +1000, 
   "Web Express Humbug email news feed" wrote:

(is there any reason this isn't "Luke" ? At the very least, From:'s aren't
that different between mail and news...)

> I was wondering if anyone knew what i need to send to sendmail in order
> for it to atach a file to an email made on the fly by a "C" program. 

"Attaching" files, is done by sending a MIME-encoded message, which encodes
the file. At the level you're working there is no "attach".

sendmail will handle the "sending" part of that, and your program presumably
handles the "message" part of it, but you'll need to do something about the
"MIME-encoded" part of it.

You're then left with a choice of using a mail reader like mutt, and hoping
it supports the right command line arguments (mutt does, for example, but
may not be quite automatable enough, I dunno); finding a program that does
the MIME-encoding -- mpack comes to mind, if you have it installed i
(mpack.deb); or alternatively reading the RFCs and rolling your own MIME
parser.

> I am using the following setup to send the mail

In general, I find sending mail from a program more trouble than it's
worth. This is what scripts -- perl, bash or whatever -- are good at.

[the following is for people playing along at home; I presume these faults
are due to miscopying from your code to your mail]
 
> FILE *mail;
> char command[256] = "/usr/lib/sendmail ";
> char *destination;
> 
> destination = "me at where.it.gets/sent";
> strcpy(command,destination);
  ^^^^^^ strcat
> mail = popen(command,"w");
> if (mail = NULL) exit(0);
           ^ ==
> fprintf(mail,"From: user at the.cee.program\n");
                      ^^^^^^^^^^^^^^^^^^^^ the-cee-program at my.host.name.au

[this way you (a) can redirect replies somewhere appropriate, and (b)
 if the mail goes off somewhere stupid, other admins don't get annoyed
 trying to work out who's sending silly mail]

Cheers,
aj

-- 
Anthony Towns <aj at humbug.org.au> <http://azure.humbug.org.au/~aj/>
I don't speak for anyone save myself. PGP encrypted mail preferred.

      ``It's not a vision, or a fear. It's just a thought.''
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 434 bytes
Desc: not available
URL: <http://lists.humbug.org.au/pipermail/general/attachments/19980529/0825df36/attachment.sig>


More information about the General mailing list