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

Posted on 2006-05-19
Last Modified: 2011-09-20
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 !
Question by:65zgtre45rr

    Author Comment

    LVL 24

    Accepted Solution

    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.



    Author Comment

    I think that my qustion was clear :) Anyon whant 5000 points ?
    LVL 14

    Expert Comment


    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
    LVL 22

    Assisted Solution

    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:"

    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.

    THAT's IT !

    LVL 24

    Expert Comment

    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.

    LVL 24

    Expert Comment

    There is a program example here... (I am drolling for the 5000 pts)
    LVL 22

    Expert Comment

    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.  

    LVL 2

    Expert Comment

    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.
    LVL 1

    Assisted Solution

    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:\n";
    char* from = "From:\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;

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
    Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode ( They will have you believe that Unicode requires you to use…
    Video by: Grant
    The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
    The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

    755 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

    26 Experts available now in Live!

    Get 1:1 Help Now