/*
forprogman@mail.ru
pass:progman
*/
#include <windows.h>
#include "base64.h"
#include <iostream.h>
#include <conio.h>
main()
{
int a,b;
hostent *h;
char *user="forprogman";
char *psw="progman";
char *Ip=new char[150];
char *in=new char[1000];
char *out=new char[1000];
char *b64=new char[1000];
SOCKET s;SOCKADDR_IN adr;
WSADATA wsd;
WSAStartup(MAKEWORD(1,1),&wsd);
h=gethostbyname("smtp.mail.ru");
sprintf(Ip,"%d.%d.%d.%d",(unsigned char)h->h_addr_list[0][0],(unsigned char)h->h_addr_list[0][1],(unsigned char)h->h_addr_list[0][2],(unsigned char)h->h_addr_list[0][3]);
adr.sin_family=AF_INET;
adr.sin_addr.s_addr =inet_addr(Ip);
adr.sin_port = htons(25);
s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
connect( s,(sockaddr *)&adr, sizeof(adr));
recv(s,in,1000,0);
printf("%s",in,"\n");
memset(in,NULL,1000);
strcpy(out,"EHLO server\n");
send(s,out,strlen(out),0);
recv(s,in,1000,0);
printf("%s",in,"\n");
memset(in,NULL,1000);
memset(out,NULL,1000);
strcpy(out,"AUTH LOGIN\n");
send(s,out,strlen(out),0);
recv(s,in,1000,0);
in+=3;
base64_decode(in,strlen(in),b64,1000);
printf("%s",b64,"\n");
memset(in,NULL,1000);
memset(out,NULL,1000);
memset(b64,NULL,1000);
base64_encode(user,strlen(user),b64,a);
strcat(b64,"\n");
send(s,b64,strlen(b64),NULL);
recv(s,in,1000,0);
memset(b64,NULL,1000);
in+=3;
base64_decode(in,strlen(in),b64,1000);
printf("%s",b64,"\n");
memset(in,NULL,1000);
memset(out,NULL,1000);
memset(b64,NULL,1000);
base64_encode(psw,strlen(psw),b64,b);
strcat(b64,"\n");
send(s,b64,strlen(b64),0);
recv(s,in,1000,0);
printf("%s",in,"\n");
printf("%s",b64,"\n");
closesocket(s);
WSACleanup();
getch();
}
проблема с smtp авторизацией
Код:
На отправленный в base64 пароль выдает 535ю ошибку.Хотя отправленный тем же способом логин нормально проходит.Немогу понять в чем дело :confused: