Link to home
Start Free TrialLog in
Avatar of jurij
jurij

asked on

sending mails with popen/telnet

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);
Avatar of samri
samri
Flag of Malaysia image

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.
Avatar of jurij
jurij

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of samri
samri
Flag of Malaysia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jurij

ASKER

I decided to send emails a different way(using telnet from my program)..
Tnx for all the help!
you're welcome.

happy holidays.