[Last Call] Learn how to a build a cloud-first strategyRegister Now


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

Posted on 2006-05-19
Medium Priority
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
  • 2
  • 2
  • 2
  • +4

Author Comment

ID: 16722634
LVL 24

Accepted Solution

fridom earned 672 total points
ID: 16723221
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

ID: 16724099
I think that my qustion was clear :) Anyon whant 5000 points ?
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 14

Expert Comment

ID: 16724117

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

Assisted Solution

grg99 earned 664 total points
ID: 16741720
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.


LVL 24

Expert Comment

ID: 16741782
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

ID: 16741900
There is a program example here... (I am drolling for the 5000 pts) http://www.muquit.com/muquit/software/mailsend/mailsend.html
LVL 22

Expert Comment

ID: 16742596
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.  


Expert Comment

ID: 16805964
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.

Assisted Solution

poid99 earned 664 total points
ID: 16808101
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;

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.

834 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