#include"windows.h"
#include"stdio.h"
#include"winsock2.h"
main()
{
SOCKET sock;
WSADATA wsaData;
WSAStartup(0x0002,&wsaData);
sock=socket(AF_INET,SOCK_STREAM,0);
if(sockINVALID_SOCKET)
{
WSACleanup();
return -1;
}
struct sockaddr_in to;
memset(&to,0,sizeof(to));
to.sin_addr.S_un.S_addr=inet_addr(“smtp服务器ip”);
to.sin_family=AF_INET;
to.sin_port=htons(25);
int r;
r=connect(sock,(struct sockaddr*)&to,sizeof(to));
if(rSOCKET_ERROR)
{
printf(“connect error:%d\n”,WSAGetLastError());
WSACleanup();
return 1;
}
char buf[100];
send(sock,“helo smtp.a.com\r\n”,strlen(“helo smtp.a.com\r\n”),0); //helo smtp服务器名
send(sock,“AUTH LOGIN\r\n”,strlen(“AUTH LOGIN\r\n”),0);
send(sock,“base64编码用户名\r\n”,strlen(“base64编码用户名\r\n”),0);