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

x
?
Solved

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

Posted on 2006-05-19
13
Medium Priority
?
277 Views
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 !
0
Comment
Question by:65zgtre45rr
  • 2
  • 2
  • 2
  • +4
10 Comments
 

Author Comment

by:65zgtre45rr
ID: 16722634
Ok
0
 
LVL 24

Accepted Solution

by:
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.
http://johnwiggins.net/jwsmtp/

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

Regards
Friedrich



0
 

Author Comment

by:65zgtre45rr
ID: 16724099
I think that my qustion was clear :) Anyon whant 5000 points ?
0
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

by:cwwkie
ID: 16724117
65zgtre45rr,

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

Assisted Solution

by:grg99
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.

THAT's IT !

0
 
LVL 24

Expert Comment

by:fridom
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.

Regards
Friedrich
0
 
LVL 24

Expert Comment

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

Expert Comment

by:grg99
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.  

0
 
LVL 2

Expert Comment

by:fpintos
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.
0
 
LVL 1

Assisted Solution

by:poid99
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>

int
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";

if(!pipe(dapipe))
{
  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));
  close(dapipe[1]);

  if (!(pid = fork()))
  {
    dup2(dapipe[0],0);
    execv("/usr/sbin/sendmail", args);
  }
}

waitpid(pid, &status, 0);

return 0;
}
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