Sending e-mail from C program

Relli

Weaksauce
Joined
Jan 16, 2001
Messages
98
I wrote a program that looks at a file's properties and generates a little file in the htdocs of my apache directory.

I want to add an option to e-mail a link to the file. Does anyone know how to access sendmail from a c program other than system("mail [email protected]"); I would like to use actual system calls or C functions, but I don't know what they are or even what libraries they are in. I tried some google'ing, but I couldn't get anything on C, just PHP, ASP, and Perl. I even browsed through the source of Mutt, but it was a little more involved than I needed.
 
Check this company out. In particular, you probably want this. I don't know what "standard" libraries might exist for C, but this should fit the bill regardless. Hope that helps!
 
standard libraries = manually open up a socket connection, follow the RFC for smtp to transfer the proper packets to the mail server, and then close the socket.
 
dear sweet lord ... sendmail. If you must, consider doh's approach. She's probably right.

I tried that monolithic junker once. I'm a qmail diehard now. I realize that doesn't help you much, I'm just planting the seeds of knowledge :)
 
Thanks for the input.

I was thinking more along the lines of opening a socket manually, then having some functions that used smtp directly. Like a mail structure you filled in with to, from, data, etc. and then a send() function that put that structure in SMTP format and transmits it to the server.

I think I'll just write my own. For no more than I need, I don't think it'll be to hard. I've done socket programming before, only to send and recieve messages. This shouldn't be any harder than that, except parsing response codes and sending SMTP messages.

Again, thanks for the input.

BTW: I switched sendmail out for qmail on the office mail server long ago. :)
 
I saw that while searching around. They just give you dll's which would work fine if they included the source so you didn't have to use it on Windows. Plus, it isn't free. I hate to pay that much when I can do it myself. I found this while searching as well, http://libsmtp.berlios.de. It open source. It may help if anyone else runs into this. I will probably use libsmtp for now until I can get time to develp my own.
 
sending basic messages over smtp should be dirt simple. The protocol is REALLY easy. Hell, I've telneted into an SMTP server and send a message by typing the commands. As long as you understand the socket part and don't have complex messages it should take much. Consult the SMTP rfc, http://www.cse.ohio-state.edu/cgi-bin/rfc/rfc0821.html
 
Back
Top