sending mails with popen/telnet

jurij
jurij used Ask the Experts™
on
I want to send emails from a c++ console app using ppoen and telnet.. what am I doing wrong?
My code:
 FILE *fp=popen("/bin/telnet mail.server.com 25","w");
 fprintf(fp,"HELO mail.server.com\n");
 fprintf(fp,"MAIL From: from@server.com\n");
 fprintf(fp,"RCPT To: to@server.com\n");
 fprintf(fp,"DATA\n");
 fprintf(fp,"BLA BLA BLA :) \n");
 fprintf(fp,".\n");
 fprintf(fp,"QUIT\n");

 fclose(fp);
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
jurij,

I do not have C knowlegde.

But, some note:  HELO is followed by your hostname and not the remote SMTP.  In most cases, it should be ok.

Another, how about using from\@server.com instead of from@server.com

just a thought.

Author

Commented:
Actualy I send server's virual addres, that my domain points to - something like mail.mydomail.com - but you're probably right - anyway it works if I do it on my own - i just copied the lines I used when telneting to the server.
I think the problem is somewhere else - telnet is like a two way stream, but i can just write or read - or am I mistaking?
What is the difference beetwen from\@server.com and from@server.com?
TNX
Commented:
jurij,

in some language, PERL for example @ will denote array type variable.  Not sure about C, so if we really want the string @something, then using @something will be a reference to an array with label something, so \@something will actuall mean @someting (gee.. confusing).

anyway, I would think that you are on the right track about the "stream".  yes telnet do establist a two-way data stream (need to reconfirm this with some socket programmer).

cheers.

Author

Commented:
I decided to send emails a different way(using telnet from my program)..
Tnx for all the help!

Commented:
you're welcome.

happy holidays.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial