Click to See Complete Forum and Search --> : Send Email through C/C++ Linux


thl
November 7th, 2006, 03:26 AM
I would like create a program in C/C++ to send email using smtp.

Does anyone has this experience and can share?

Thanks

exterminator
November 7th, 2006, 04:59 AM
Search for already built libs that will help you with this.. however a system command would also do the job.

Do man mail or mailx or Mail on your unix/linux terminal to know details.

SuperKoko
November 7th, 2006, 09:05 AM
The sendmail program is very complete AFAIK.

thl
November 8th, 2006, 03:45 AM
Did you mention "sendemail" program?

I am able to get the source code for sendemail, but there are a list of folders and files, which is the one that I should use?

Thanks

SuperKoko
November 8th, 2006, 05:30 AM
You don't have to use sendmail's source code.
It's designed to be invoked as a child process of your process with a fork/exec or a similar mechanism.

You have to:

Learn the command line interface of sendmail described in the man page:
http://unixhelp.ed.ac.uk/CGI/man-cgi?sendmail
Invoke sendmail, redirecting its standard input, and eventually, the standard output & standard error stream.

Note: sendmail can be launched as a daemon with the -bd option.
It can be useful if you want that mails can be sent even when your program is exited, useful for large messages & non-responding SMTP destination servers.


Sendmail is not intended as a user interface routine; other programs
provide user-friendly front ends; sendmail is used only to deliver pre-
formatted messages.

sendmail is designed for this type of usage.
It's simple & powerful.