![](wink.gif)
![](smile.gif)
![](http://www.baskuenen.myweb.nl/images/title.jpg)
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
//----------------------------------------------------------------------------#include <stdio.h>#include <string.h>#include <windows.h>#include <winsock.h>//----------------------------------------------------------------------------#define SMTP_PORT 25#define MAXBUF 4096//---------------------------------------------------------------------------void send_smtpcmd(SOCKET sock, char *szCmd){ char szReply[MAXBUF]; int iLen; send(sock, szCmd, strlen(szCmd), 0); iLen = recv(sock, szReply, MAXBUF, 0); szReply[iLen] = 0; printf(szReply);}//---------------------------------------------------------------------------main(){ WORD wVersionRequested = MAKEWORD( 2, 0 ); WSADATA wsa; if (WSAStartup(wVersionRequested , &wsa)!=0) { printf("Winsock Initialization failed.\n"); return -1; } SOCKET sock; if ((sock=socket(AF_INET,SOCK_STREAM,0))==INVALID_SOCKET) { printf("Can not create socket.\n"); return -1; } char *szSMTPServer = "www.hotmail.com"; struct hostent *hs; if ((hs=gethostbyname(szSMTPServer))==NULL) { printf("Can not resolve specified host.\n"); return -1; } SOCKADDR_IN addr; addr.sin_family = AF_INET; addr.sin_port = htons(SMTP_PORT); memcpy((void *)&addr.sin_addr.s_addr, hs->h_addr, hs->h_length); if (connect(sock,(LPSOCKADDR)&addr,sizeof(addr))==SOCKET_ERROR) { printf("Can not connect to specified host.\n"); return -1; } char packetbuf[MAXBUF]; recv(sock, packetbuf, MAXBUF, 0); printf("BANNER: %s\n", packetbuf); send_smtpcmd(sock, "MAIL FROM: <me@domain.web>\r\n"); send_smtpcmd(sock, "RCPT TO: <baskuenen@hotmail.com>\r\n"); //can be repeated send_smtpcmd(sock, "DATA\r\n"); send_smtpcmd(sock, "Subject: Test HTML mail.\r\n" "MIME-Version: 1.0\r\n" "Content-Type: text/html; \r\n" " charset=\"iso-8859-1\"\r\n" "Content-Transfer-Encoding: quoted-printable\r\n" ".\r\n"); closesocket(sock); printf("Done.\n"); return 0;}//------------------------------------------------------------------------------