#include <windows.h>
#include <winsock.h>
#include <stdio.h>
void abc(char *p)
{
FILE *fp=fopen("z.txt","a+");
fprintf(fp,"%s\n",p);
fclose(fp);
}
struct sockaddr_in A;
WSADATA W;
SOCKET S;
char aa[100];
int i;
struct hostent *H;
char R[10000];
int _stdcall WinMain(HINSTANCE ii, HINSTANCE j, char *k, int l)
{
WSAStartup (0x101, &W);
S = socket(AF_INET, SOCK_STREAM,0);
A.sin_family=AF_INET;
A.sin_port = htons(25);
H=gethostbyname("giasbm01.vsnl.net.in");
A.sin_addr.s_addr=*((unsigned long *) H->h_addr);
i=connect(S,(struct sockaddr *) &A,sizeof(A));
sprintf(aa,"connect %d",i);
abc(aa);
strset(aa,' ');
i=recv(S,R,10000,0);
sprintf(aa,"recv %d R %s",i,R);
abc(aa);
strset(aa,' ');
strcpy(R,"HELO vijay.com\r\n");
i=send(S,R,strlen(R),0);
sprintf(aa,"send %d ",i);
abc(aa);
strset(aa,' ');
i=recv(S,R,10000,0);
sprintf(aa,"recv %d R %s",i,R);
abc(aa);
strset(aa,' ');
strcpy(R,"MAIL FROM:<vijay1@giasbm01.vsnl.net.in>\r\n");
i=send(S,R,strlen(R),0);
sprintf(aa,"send %d ",i);
abc(aa);
strset(aa,' ');
i=recv(S,R,10000,0);
sprintf(aa,"recv %d R %s",i,R);
abc(aa);
strset(aa,' ');
strcpy(R,"RCPT TO:<ravi@giasbm01.vsnl.net.in>\r\n");
i=send(S,R,strlen(R),0);
sprintf(aa,"send %d ",i);
abc(aa);
strset(aa,' ');
i=recv(S,R,10000,0);
sprintf(aa,"recv %d R %s",i,R);
abc(aa);
strset(aa,' ');
strcpy(R,"DATA\r\n");
i=send(S,R,strlen(R),0);
sprintf(aa,"send %d ",i);
abc(aa);
strset(aa,' ');
i=recv(S,R,10000,0);
sprintf(aa,"recv %d R %s",i,R);
abc(aa);
strcpy(R,"To: aaa.com\r\n");
i=send(S,R,strlen(R),0);
sprintf(aa,"send %d ",i);
abc(aa);
strset(aa,' ');
strcpy(R,"FROM: vijay1@giasbm01.vsnl.net.in\r\n");
i=send(S,R,strlen(R),0);
sprintf(aa,"send %d ",i);
abc(aa);
strset(aa,' ');
strcpy(R,"DATE: 10 Jan 95 13:24 PST\r\n");
i=send(S,R,strlen(R),0);
sprintf(aa,"send %d ",i);
abc(aa);
strset(aa,' ');
strcpy(R,"MESSAGE_ID: <123@e.com>\r\n");
i=send(S,R,strlen(R),0);
sprintf(aa,"send %d ",i);
abc(aa);
strset(aa,' ');
strcpy(R,"Hello\r\n");
i=send(S,R,strlen(R),0);
sprintf(aa,"send %d ",i);
abc(aa);
strset(aa,' ');
strcpy(R,"How are you\r\n");
i=send(S,R,strlen(R),0);
sprintf(aa,"send %d ",i);
abc(aa);
strset(aa,' ');
strcpy(R,".\r\n");
i=send(S,R,strlen(R),0);
sprintf(aa,"send %d ",i);
abc(aa);
strset(aa,' ');
i=recv(S,R,10000,0);
sprintf(aa,"recv %d R %s",i,R);
abc(aa);
strset(aa,' ');
strcpy(R,"QUIT\r\n");
i=send(S,R,strlen(R),0);
sprintf(aa,"send %d ",i);
abc(aa);
strset(aa,' ');
i=recv(S,R,10000,0);
sprintf(aa,"recv %d R %s",i,R);
abc(aa);
return 0;
}