#include <windows.h>
int main(void)
{
int message_length;
char message[100]="this is a test message";
char buffer[100];
SOCKET sockfd;WSADATA wsaData;
struct sockaddr_in dest_addr;
WSAStartup(MAKEWORD(2, 0),&wsaData);
sockfd=socket(AF_INET,SOCK_STREAM,0);
dest_addr.sin_family=AF_INET;
dest_addr.sin_port=htons(25);
dest_addr.sin_addr.s_addr=inet_addr("192.168.1.1");
connect(sockfd, (struct sockaddr *)&dest_addr,sizeof(dest_addr));
strcpy(buffer,"HELO abc.com\n");
send(sockfd, buffer, (strlen(buffer)), 0);
recv(sockfd, buffer, (strlen(buffer)), 0);
sleep(500);
strcpy(buffer,"MAIL FROM:<abc@yahoo.com>\n");
send(sockfd, buffer, (strlen(buffer)), 0);
recv(sockfd, buffer, (strlen(buffer)), 0);
sleep(500);
strcpy(buffer,"RCPT TO:<abc@zyz.com>\n");
send(sockfd, buffer, (strlen(buffer)), 0);
recv(sockfd, buffer, (strlen(buffer)), 0);
sleep(500);
strcpy(buffer,"DATA\n");
send(sockfd, buffer, (strlen(buffer)), 0);
recv(sockfd, buffer, (strlen(buffer)), 0);
sleep(500);
strcpy(buffer,"To:abc@zyz.com\n");
strcat(buffer,"From:abc@yahoo.com\n");
strcat(buffer,"Subject:test mail\n");
send(sockfd, buffer, (strlen(buffer)), 0);
memset(&buffer, 0, sizeof(buffer));
strcat(buffer,message);
strcat(buffer,"\n.\n");
send(sockfd, buffer, (strlen(buffer)), 0);
recv(sockfd, buffer, (strlen(buffer)), 0);
sleep(500);
strcpy(buffer,"QUIT\n");
send(sockfd, buffer, (strlen(buffer)), 0);
recv(sockfd, buffer, (strlen(buffer)), 0);
sleep(500);
closesocket(sockfd);
WSACleanup();
return (0);
}