• C

E-mail sender for linux in c ! - 5000 points !

I will give 5000 points (10 x 500) for this solution. I need the folowing:

E-mail sender for linux:
- must be written in c for *nix and compiled with gcc with no errors
- mail list, mail body, mail subject, mail from needs to be loded from txt files
- smtp server and port will be setup in program variable
- must send html body message
- it needs to send mail to every mail in mail list file

This would be it !

Thank you !
Who is Participating?
fridomConnect With a Mentor CEO/ProgrammerCommented:
Well you have some mail transport agent on any unix. So the answer is using that.
Read in the elements you like to have into the program. Modify them in a way that the mail transport agent can handle at, call out and let the agent do it's job.

E.g you can pull in all the needed information. then write out one file and after that you
call out to the agent, or you can use some library build for that, see e.g.

It needs some work, and quite some time. So no I'm not going to implement that for you just for EE-points.


65zgtre45rrAuthor Commented:
65zgtre45rrAuthor Commented:
I think that my qustion was clear :) Anyon whant 5000 points ?
The IT Degree for Career Advancement

Earn your B.S. in Network Operations and Security and become a network and IT security expert. This WGU degree program curriculum was designed with tech-savvy, self-motivated students in mind – allowing you to use your technical expertise, to address real-world business problems.


it has been tried before, but it is not possible to give more then 500 points. Additional questions will be deleted. And anyway, we cannot do anything with the points. Why would we do your work just for those points?

You can look at the member profiles of the experts here, many of the profiles include contact information or a website. So you can contact them directly to ask this, or use a site like http://rentacoder.com/.
grg99Connect With a Mentor Commented:
We can't give you the whole thing.  YOu have to take a good whack at it and then we can help.

For starters, you need to learn the SMTP protocol.  Google for "RFC SMTP".

It's really simple.  You connect to port 25.

You send "Mail from: foo@bar.zzz"

You wait for "xxx ok:

You send "RCPT TO:  goober@foobar.com"

You want for a response.

You send "CC to:    etc..."

You want for the response.

You send "DATA"
You wait for the response line.

You send the message.

You send "."

You wait for a response line.

You send "quit".

You want for the response.


Well grg 99 you are right, but parsing that all yourself etc has to be done. So my suggestion still stands, use some library for it and or
use the system provided mailt transport agent.

There is a program example here... (I am drolling for the 5000 pts) http://www.muquit.com/muquit/software/mailsend/mailsend.html
The only parsing you have to do is to look at the first character of each line the SMTP server send you.

I agree it's not a great idea to reinvent the wheel though.

But most of the wheels I've borrowed have been too big, too small, too light, too heavy, flat on one or more sides, needing exactly 31.97 pounds of air, or having a tendency to blow up at odd moments.  

Is there any reason why your solution have to be in C?

Perl is much better at doing this kind of job than C and you can use all the existing SMTP modules to do your parsing for you.
poid99Connect With a Mentor Commented:
I think the following is kinda fridom's idea.
The following "C" code uses the sendmail utility.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <string.h>

main(int argc, char** argv)
char * args[] = {"sendmail", "-t", NULL};
pid_t pid=0;
int status=0;
int dapipe[2]={0,0};
char* to = "To: them@their.email.com\n";
char* from = "From: you@your.email.com\n";
char* subject = "Subject: SUBJECT\n";
char* str = "The text of your message.\n";

  write(dapipe[1], to, strlen(to));
  write(dapipe[1], from, strlen(from));
  write(dapipe[1], subject, strlen(subject));
  write(dapipe[1], "\n", 1);
  write(dapipe[1], str, strlen(str));

  if (!(pid = fork()))
    execv("/usr/sbin/sendmail", args);

waitpid(pid, &status, 0);

return 0;
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.