#include <winsock2.h>
#include <windows.h>
#include<stdio.h>
#pragma comment(lib, "Ws2_32.lib")
#include <iostream>
using namespace std;
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd, int nShow)
{
WSADATA wsaData;
WSAStartup(MAKEWORD(1,1), &wsaData);
SOCKET Sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if(Sock == INVALID_SOCKET)
{
WSACleanup();
return INVALID_SOCKET;
};
LPHOSTENT hostEntry;
in_addr iaHost;
SOCKADDR_IN Addr_in;
Addr_in.sin_family=AF_INET;
Addr_in.sin_addr.s_addr=inet_addr("10.0.2.6");
Addr_in.sin_port=htons(25);
if ( connect(Sock,(LPSOCKADDR)&Addr_in,sizeof(struct Addr_in)) == SOCKET_ERROR)
{
WSACleanup();
return INVALID_SOCKET;
};
struct Email { LPSTR sender , recipient , message , subject; };
Email e = { "vin@jkdbk.com" , "vinod@vrk.com" , "hi" , "joke"};
LPSTR lpszBuff = new char[500];
//LPSTR vin=new char[500];
recv(Sock,lpszBuff,500,0);
cout << lpszBuff;
sprintf(lpszBuff,"HELO Mail-Server\r\n");
send(Sock,lpszBuff,strlen(lpszBuff),0);
recv(Sock,lpszBuff,100,0);
cout << lpszBuff;
//for (int i = 0;i>=0; i++) {
sprintf(lpszBuff,"MAIL FROM: %s\r\n",e.sender);
send(Sock,lpszBuff,strlen(lpszBuff),0);
recv(Sock,lpszBuff,100,0);
sprintf(lpszBuff,"RCPT TO: %s\r\n",e.recipient);
send(Sock,lpszBuff,strlen(lpszBuff),0);
recv(Sock,lpszBuff,100,0);
sprintf(lpszBuff,"DATA\r\nFROM: <%s>\r\nSUBJECT: %s\r\n%s\r\n.\r\n",e.sender,e.subject,e.message);
send(Sock,lpszBuff,strlen(lpszBuff),0);
recv(Sock,lpszBuff,100,0);
//}
sprintf(lpszBuff,"QUIT");
send(Sock,lpszBuff,strlen(lpszBuff),0);
//recv(s,lpszBuff,100,0);
delete lpszBuff;
WSACleanup();
exit(0);
}
Это программа для отправки почты на почтовый сервер, адрес которого указан
Это дает мне ошибку
ошибка C2027: использование неопределенного типа 'WinMain :: Addr_in' ..