Thread: [Dev-C++] send()/recv() SMTP commands
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: KrowniX \(\)--\(\) <kr...@ya...> - 2006-05-05 12:11:06
|
Hi,
I ´m having trouble in send() and recv() smtp commands, I already write my code, and there´s no error, and works without problems but I still don´t send e-mails...
I´m posting my code here, could you take a look a maybe tell me where I´m wrong?
If someone need the .dev file to try help me, let me know that I will send it to you.
Bye,
Krownix
#include <stdio.h>
#include <stdlib.h>
#include <winsock2.h>
#include "base64.h"
int Help()
{
printf("Modo de uso:\n");
printf(" -h Help do programa\n");
printf(" -v Versão do programa\n\n");
printf(" -s IP do servidor SMTP\n");
printf(" -u Usuario do servidor SMTP\n");
printf(" -p Senha do servidor SMTP\n");
printf(" -f Email de quem esta enviando\n");
printf(" -t Email de quem irá receber o email\n");
printf(" -b Assunto do email\n");
printf(" -d Corpo da mensagem\n");
printf(" -r Caminho do arquivo que será enviado como corpo\n\n");
printf("Lembrando que usando -b e/ou -d será necessario usar o simbolo %20 ao invez de espaço\n\n");
printf("Exempo:\n");
printf("emailer -s 209.191.85.254 -u meuuser -p senhateste -f me...@ya... -t meu...@gm... -b Assunto%20do%20meu%20email -r C:\\corpo.txt\n");
return 0;
}
int Version()
{
printf("Versao: 0.1\n");
}
char *strreplace(char *str)
{
char *strf;
int i, j=0;
strf=malloc(strlen(str) * sizeof(char));
for(i=0; i<strlen(str); i++)
{
if(str[i] == '%')
if(str[i+1] == '2')
if(str[i+2] == '0')
{
strf[j]=' ';
i=i+2;
j++;
continue;
}
strf[j]=str[i];
j++;
}
strf[j]='\0';
return strf;
}
int main(int argc, char **argv)
{
/*if(argc>6)
{
Help();
exit(0);
}*/
int i=0, j=0; //Contadores
char *Servidor, *Usuario, *Senha, *From, *To, *Subject, *Body;
for (i=1; i<argc; i++) //Looping que percorre os argumentos
{
switch(argv[i][1]) //Transferencia dos argumentos para as variaveis
{
case 'v': //Version. Mostra a versão do programa
Version();
exit(0);
break;
case 'h': //Help. Chama o Help do programa
Help();
exit(0);
break;
case 's': //Server. Endereço do servidor
i++;
Servidor=malloc(strlen(argv[i]) * sizeof(char));
strcpy(Servidor, argv[i]);
break;
case 'u': //User. Usuario do servidor
i++;
Usuario=malloc(strlen(argv[i]) * sizeof(char));
strcpy(Usuario, argv[i]);
break;
case 'p': //Password. Senha do servidor
i++;
Senha=malloc(strlen(argv[i]) * sizeof(char));
strcpy(Senha, argv[i]);
break;
case 'f': //From. Email de quem ta enviando
i++;
From=malloc(strlen(argv[i]) * sizeof(char));
strcpy(From, argv[i]);
break;
case 't': //To. Email de quem vai receber
i++;
To=malloc(strlen(argv[i]) * sizeof(char));
strcpy(To, argv[i]);
break;
case 'b': //Subject. Assunto do email
i++;
Subject=malloc(strlen(argv[i]) * sizeof(char));
strcpy(Subject, strreplace(argv[i]));
break;
case 'd': //Body. Corpo do email
i++;
Body=malloc(strlen(argv[i]) * sizeof(char));
strcpy(Body, strreplace(argv[i]));
break;
case 'r': //Body. Corpo do email com arquivo
i++;
FILE *arq=fopen(argv[i], "r");
char ch;
if(arq==NULL)
{
printf("O arquivo referente ao corpo da mensagem não existe, ou não pode ser aberto\n");
exit(0);
}
while((ch=fgetc(arq))!=EOF)
j++;
fseek(arq, -1*j*sizeof(char), 1);
Body=malloc(j * sizeof(char));
j=0;
while((ch=fgetc(arq))!=EOF) //put FILE in Body
{
Body[j]=ch;
j++;
}
Body[j]='\0';
break;
}
}
//crypt pass/user
if((Usuario!=NULL) && (Senha!=NULL))
{
char r[30];
int res, outlen;
res=encode64(Usuario, strlen(Usuario), r, strlen(Usuario)*2, &outlen);
free(Usuario);
Usuario=malloc(strlen(r) * sizeof(char));
strcpy(Usuario, r);
res=encode64(Senha, strlen(Senha), r, strlen(Senha)*2, &outlen);
free(Senha);
Senha=malloc(strlen(r) * sizeof(char));
strcpy(Senha, r);
}
WSADATA wsadata;
HOSTENT *HostInfo;
SOCKET Sck;
struct sockaddr_in Remote;
long tmpCon;
int Conexao;
char Buffer[512];
if(WSAStartup(MAKEWORD(2,0), &wsadata)!=0)
{
printf("Winsock não encontrado\n");
exit(0);
}
if(LOBYTE(wsadata.wVersion )!=2||HIBYTE(wsadata.wVersion )!=0)
{
printf("Versão do winsock antiga. Atualize o winsock\n");
exit(0);
}
Sck=socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
Remote.sin_family = AF_INET;
Remote.sin_port = htons(25);
Remote.sin_addr.s_addr = inet_addr(Servidor);
HostInfo = gethostbyname(Servidor);
if (HostInfo == NULL)
{
printf("Impossivel conectar ao servidor.\n");
exit(0);
}
Conexao=connect(Sck,(struct sockaddr *)&Remote, sizeof(Remote));
tmpCon = GetTickCount();
while(Conexao!=0)
if ((GetTickCount()-tmpCon) > 2500) break;
if((recv(Sck, Buffer, 512, 0))==0) //check the recv()
{
printf("A conexao foi desfeita\n");
exit(0);
}
memset(Buffer, '\0', sizeof(Buffer));
if(Conexao==0)
{
if(Usuario==NULL)
{
send(Sck, "HELO\r\n", 6, 0);
printf("enviando helo");
if((recv(Sck, Buffer, 512, 0))==0) //check the recv()
{
printf("A conexao foi desfeita\n");
exit(0);
}
else
{
if(strstr(Buffer, "250")==0)
{
printf("Erro inexperado.\n");
send(Sck, "quit\r\n", 6, 0); //close the connection
exit(0);
}
}
printf("%s\n", Buffer);
}
else
{
/**********************************/
send(Sck, "EHLO ", 5, 0); //sendsEHLO
send(Sck, Servidor, strlen(Servidor), 0); //sends EHLO
send(Sck, "\r\n", 2, 0); //sends EHLO
if((recv(Sck, Buffer, 512, 0))==0) //check the recv()
{
printf("A conexao foi desfeita\n");
exit(0);
}
else
{
if(strstr(Buffer, "250")==0)
{
printf("Erro inexperado.\n");
send(Sck, "quit\r\n", 6, 0); //close the connection
exit(0);
}
}
printf("%s\n", Buffer);
memset(Buffer, '\0', sizeof(Buffer));
/**********************************/
send(Sck, "AUTH LOGIN\r\n", 12, 0); //sends AUTH LOGIN
printf("\nenviando auth login");
if((recv(Sck, Buffer, 512, 0))==0) //check the recv()
{
printf("A conexao foi desfeita\n");
exit(0);
}
else
{
if(strstr(Buffer, "334")==0)
{
printf("Erro inexperado.\n");
send(Sck, "quit\r\n", 6, 0); //close the connection
exit(0);
}
}
printf("%s\n", Buffer);
memset(Buffer, '\0', sizeof(Buffer));
/**********************************/
send(Sck, Usuario, strlen(Usuario), 0); //sends the user
send(Sck, "\r\n", 2, 0);
if((recv(Sck, Buffer, 512, 0))==0) //check the recv()
{
printf("A conexao foi desfeita\n");
exit(0);
}
else
{
if(strstr(Buffer, "334")==0)
{
printf("Erro inexperado.\n");
send(Sck, "quit\r\n", 6, 0); //close the connection
exit(0);
}
}
printf("%s\n", Buffer);
memset(Buffer, '\0', sizeof(Buffer));
/**********************************/
send(Sck, Senha, strlen(Senha), 0); //send the password
send(Sck, "\r\n", 2, 0);
printf("\nenviando senha: %s", Senha);
if((recv(Sck, Buffer, 512, 0))==0) //check the recv()
{
printf("A conexao foi desfeita\n");
exit(0);
}
else
{
if(strstr(Buffer, "235")==0)
{
printf("Erro inexperado.\n");
send(Sck, "quit\r\n", 6, 0); //close the connection
//exit(0);
}
}
printf("%s\n", Buffer);
memset(Buffer, '\0', sizeof(Buffer));
}
/**********************************/
send(Sck, "MAIL FROM: ", 11, 0); //who is sending the mail
send(Sck, From, strlen(From), 0);
send(Sck, "\r\n", 2, 0);
if((recv(Sck, Buffer, 512, 0))==0) //check the recv()
{
printf("A conexao foi desfeita\n");
exit(0);
}
else
{
if(strstr(Buffer, "250")==0)
{
printf("Erro inexperado.\n");
send(Sck, "quit\r\n", 6, 0); //close the connection
exit(0);
}
}
printf("%s\n", Buffer);
memset(Buffer, '\0', sizeof(Buffer));
/**********************************/
send(Sck, "RCPT TO: ", 9, 0); //who will receive the mail
send(Sck, To, strlen(To), 0);
send(Sck, "\r\n", 2, 0);
if((recv(Sck, Buffer, 512, 0))==0) //check the recv()
{
printf("A conexao foi desfeita\n");
exit(0);
}
else
{
if(strstr(Buffer, "250")==0)
{
printf("Erro inexperado.\n");
send(Sck, "quit\r\n", 6, 0); //Fecha a conexao
exit(0);
}
}
printf("%s\n", Buffer);
memset(Buffer, '\0', sizeof(Buffer));
/**********************************/
send(Sck, "DATA\r\n", 6, 0); //Diz ao servidor que eu estou pronto pra escrever o email
if((recv(Sck, Buffer, 512, 0))==0) //Verifica a resposta
{
printf("A conexao foi desfeita\n");
exit(0);
}
else
{
if(strstr(Buffer, "354")==0)
{
printf("Erro inexperado.\n");
send(Sck, "quit\r\n", 6, 0); //Fecha a conexao
exit(0);
}
}
printf("%s\n", Buffer);
memset(Buffer, '\0', sizeof(Buffer));
/**********************************/
/* thats the header of the mail
*
*/
send(Sck, "From: ", 6, 0);
send(Sck, From, strlen(From), 0);
send(Sck, "\r\n", 2, 0);
send(Sck, "To: ", 4, 0);
send(Sck, To, strlen(To), 0);
send(Sck, "\r\n", 2, 0);
send(Sck, "Subject: ", 9, 0);
send(Sck, Subject, strlen(Subject), 0);
send(Sck, "\r\n", 2, 0);
send(Sck, "MIME-Version: 1.0\r\n", 19, 0);
send(Sck, "Content-Type: multipart/alternative;\r\n", 38, 0);
send(Sck, " boundary=----=_Part_1255_4525121.1146192955226\r\n", 56, 0);
send(Sck, "\r\n", 2, 0);
send(Sck, "------=_Part_1255_4525121.1146192955226\r\n", 41, 0);
send(Sck, "Content-Type: text/plain; charset=ISO-8859-1; format=flowed\r\n", 61, 0);
send(Sck, "Content-Transfer-Encoding: quoted-printable\r\n", 45, 0);
send(Sck, "Content-Disposition: inline\r\n", 29, 0);
send(Sck, "\r\n", 2, 0);
send(Sck, Body, strlen(Body), 0);
send(Sck, "\r\n", 2, 0);
send(Sck, "------=_Part_1255_4525121.1146192955226--\r\n", 43, 0);
send(Sck, ".\r\n", 3, 0);
if((recv(Sck, Buffer, 512, 0))==0) //Verifica a resposta
{
printf("A conexao foi desfeita\n");
exit(0);
}
else
{
if(strstr(Buffer, "250")==0)
{
printf("Erro inexperado.\n");
send(Sck, "quit\r\n", 6, 0); //Fecha a conexao
exit(0);
}
}
printf("%s\n", Buffer);
send(Sck, "quit\r\n", 6, 0); //Fecha a conexao
memset(Buffer, '\0', sizeof(Buffer));
/**********************************/
}
return 0;
}
---------------------------------
Yahoo! doce lar. Faça do Yahoo! sua homepage. |
|
From: KrowniX \(\)--\(\) <kr...@ya...> - 2006-05-05 13:11:40
|
Sorry people...
I found out why I can´t send e-mails...it´s becouse the configuration of the proxy that doesn´t allowed smtp communication..
Sorry ..but if anyone wants...knock yourself out with my code...it´s working..
Bye
Kronix
"KrowniX ()--()" <kr...@ya...> escreveu: Hi,
I ´m having trouble in send() and recv() smtp commands, I already write my code, and there´s no error, and works without problems but I still don´t send e-mails...
I´m posting my code here, could you take a look a maybe tell me where I´m wrong?
If someone need the .dev file to try help me, let me know that I will send it to you.
Bye,
Krownix
#include <stdio.h>
#include <stdlib.h>
#include <winsock2.h>
#include "base64.h"
int Help()
{
printf("Modo de uso:\n");
printf(" -h Help do programa\n");
printf(" -v Versão do programa\n\n");
printf(" -s IP do servidor SMTP\n");
printf(" -u Usuario do servidor SMTP\n");
printf(" -p Senha do servidor SMTP\n");
printf(" -f Email de quem esta enviando\n");
printf(" -t Email de quem irá receber o email\n");
printf(" -b Assunto do email\n");
printf(" -d Corpo da mensagem\n");
printf(" -r Caminho do arquivo que será enviado como corpo\n\n");
printf("Lembrando que usando -b e/ou -d será necessario usar o simbolo %20 ao invez de espaço\n\n");
printf("Exempo:\n");
printf("emailer -s 209.191.85.254 -u meuuser -p senhateste -f me...@ya... -t meu...@gm... -b Assunto%20do%20meu%20email -r C:\\corpo.txt\n");
return 0;
}
int Version()
{
printf("Versao: 0.1\n");
}
char *strreplace(char *str)
{
char *strf;
int i, j=0;
strf=malloc(strlen(str) * sizeof(char));
for(i=0; i<strlen(str); i++)
{
if(str[i] == '%')
if(str[i+1] == '2')
if(str[i+2] == '0')
{
strf[j]=' ';
i=i+2;
j++;
continue;
}
strf[j]=str[i];
j++;
}
strf[j]='\0';
return strf;
}
int main(int argc, char **argv)
{
/*if(argc>6)
{
Help();
exit(0);
}*/
int i=0, j=0; //Contadores
char *Servidor, *Usuario, *Senha, *From, *To, *Subject, *Body;
for (i=1; i<argc; i++) //Looping que percorre os argumentos
{
switch(argv[i][1]) //Transferencia dos argumentos para as variaveis
{
case 'v': //Version. Mostra a versão do programa
Version();
exit(0);
break;
case 'h': //Help. Chama o Help do programa
Help();
exit(0);
break;
case 's': //Server. Endereço do servidor
i++;
Servidor=malloc(strlen(argv[i]) * sizeof(char));
strcpy(Servidor, argv[i]);
break;
case 'u': //User. Usuario do servidor
i++;
Usuario=malloc(strlen(argv[i]) * sizeof(char));
strcpy(Usuario, argv[i]);
break;
case 'p': //Password. Senha do servidor
i++;
Senha=malloc(strlen(argv[i]) * sizeof(char));
strcpy(Senha, argv[i]);
break;
case 'f': //From. Email de quem ta enviando
i++;
From=malloc(strlen(argv[i]) * sizeof(char));
strcpy(From, argv[i]);
break;
case 't': //To. Email de quem vai receber
i++;
To=malloc(strlen(argv[i]) * sizeof(char));
strcpy(To, argv[i]);
break;
case 'b': //Subject. Assunto do email
i++;
Subject=malloc(strlen(argv[i]) * sizeof(char));
strcpy(Subject, strreplace(argv[i]));
break;
case 'd': //Body. Corpo do email
i++;
Body=malloc(strlen(argv[i]) * sizeof(char));
strcpy(Body, strreplace(argv[i]));
break;
case 'r': //Body. Corpo do email com arquivo
i++;
FILE *arq=fopen(argv[i], "r");
char ch;
if(arq==NULL)
{
printf("O arquivo referente ao corpo da mensagem não existe, ou não pode ser aberto\n");
exit(0);
}
while((ch=fgetc(arq))!=EOF)
j++;
fseek(arq, -1*j*sizeof(char), 1);
Body=malloc(j * sizeof(char));
j=0;
while((ch=fgetc(arq))!=EOF) //put FILE in Body
{
Body[j]=ch;
j++;
}
Body[j]='\0';
break;
}
}
//crypt pass/user
if((Usuario!=NULL) && (Senha!=NULL))
{
char r[30];
int res, outlen;
res=encode64(Usuario, strlen(Usuario), r, strlen(Usuario)*2, &outlen);
free(Usuario);
Usuario=malloc(strlen(r) * sizeof(char));
strcpy(Usuario, r);
res=encode64(Senha, strlen(Senha), r, strlen(Senha)*2, &outlen);
free(Senha);
Senha=malloc(strlen(r) * sizeof(char));
strcpy(Senha, r);
}
WSADATA wsadata;
HOSTENT *HostInfo;
SOCKET Sck;
struct sockaddr_in Remote;
long tmpCon;
int Conexao;
char Buffer[512];
if(WSAStartup(MAKEWORD(2,0), &wsadata)!=0)
{
printf("Winsock não encontrado\n");
exit(0);
}
if(LOBYTE(wsadata.wVersion )!=2||HIBYTE(wsadata.wVersion )!=0)
{
printf("Versão do winsock antiga. Atualize o winsock\n");
exit(0);
}
Sck=socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
Remote.sin_family = AF_INET;
Remote.sin_port = htons(25);
Remote.sin_addr.s_addr = inet_addr(Servidor);
HostInfo = gethostbyname(Servidor);
if (HostInfo == NULL)
{
printf("Impossivel conectar ao servidor.\n");
exit(0);
}
Conexao=connect(Sck,(struct sockaddr *)&Remote, sizeof(Remote));
tmpCon = GetTickCount();
while(Conexao!=0)
if ((GetTickCount()-tmpCon) > 2500) break;
if((recv(Sck, Buffer, 512, 0))==0) //check the recv()
{
printf("A conexao foi desfeita\n");
exit(0);
}
memset(Buffer, '\0', sizeof(Buffer));
if(Conexao==0)
{
if(Usuario==NULL)
{
send(Sck, "HELO\r\n", 6, 0);
printf("enviando helo");
if((recv(Sck, Buffer, 512, 0))==0) //check the recv()
{
printf("A conexao foi desfeita\n");
exit(0);
}
else
{
if(strstr(Buffer, "250")==0)
{
printf("Erro inexperado.\n");
send(Sck, "quit\r\n", 6, 0); //close the connection
exit(0);
}
}
printf("%s\n", Buffer);
}
else
{
/**********************************/
send(Sck, "EHLO ", 5, 0); //sendsEHLO
send(Sck, Servidor, strlen(Servidor), 0); //sends EHLO
send(Sck, "\r\n", 2, 0); //sends EHLO
if((recv(Sck, Buffer, 512, 0))==0) //check the recv()
{
printf("A conexao foi desfeita\n");
exit(0);
}
else
{
if(strstr(Buffer, "250")==0)
{
printf("Erro inexperado.\n");
send(Sck, "quit\r\n", 6, 0); //close the connection
exit(0);
}
}
printf("%s\n", Buffer);
memset(Buffer, '\0', sizeof(Buffer));
/**********************************/
send(Sck, "AUTH LOGIN\r\n", 12, 0); //sends AUTH LOGIN
printf("\nenviando auth login");
if((recv(Sck, Buffer, 512, 0))==0) //check the recv()
{
printf("A conexao foi desfeita\n");
exit(0);
}
else
{
if(strstr(Buffer, "334")==0)
{
printf("Erro inexperado.\n");
send(Sck, "quit\r\n", 6, 0); //close the connection
exit(0);
}
}
printf("%s\n", Buffer);
memset(Buffer, '\0', sizeof(Buffer));
/**********************************/
send(Sck, Usuario, strlen(Usuario), 0); //sends the user
send(Sck, "\r\n", 2, 0);
if((recv(Sck, Buffer, 512, 0))==0) //check the recv()
{
printf("A conexao foi desfeita\n");
exit(0);
}
else
{
if(strstr(Buffer, "334")==0)
{
printf("Erro inexperado.\n");
send(Sck, "quit\r\n", 6, 0); //close the connection
exit(0);
}
}
printf("%s\n", Buffer);
memset(Buffer, '\0', sizeof(Buffer));
/**********************************/
send(Sck, Senha, strlen(Senha), 0); //send the password
send(Sck, "\r\n", 2, 0);
printf("\nenviando senha: %s", Senha);
if((recv(Sck, Buffer, 512, 0))==0) //check the recv()
{
printf("A conexao foi desfeita\n");
exit(0);
}
else
{
if(strstr(Buffer, "235")==0)
{
printf("Erro inexperado.\n");
send(Sck, "quit\r\n", 6, 0); //close the connection
//exit(0);
}
}
printf("%s\n", Buffer);
memset(Buffer, '\0', sizeof(Buffer));
}
/**********************************/
send(Sck, "MAIL FROM: ", 11, 0); //who is sending the mail
send(Sck, From, strlen(From), 0);
send(Sck, "\r\n", 2, 0);
if((recv(Sck, Buffer, 512, 0))==0) //check the recv()
{
printf("A conexao foi desfeita\n");
exit(0);
}
else
{
if(strstr(Buffer, "250")==0)
{
printf("Erro inexperado.\n");
send(Sck, "quit\r\n", 6, 0); //close the connection
exit(0);
}
}
printf("%s\n", Buffer);
memset(Buffer, '\0', sizeof(Buffer));
/**********************************/
send(Sck, "RCPT TO: ", 9, 0); //who will receive the mail
send(Sck, To, strlen(To), 0);
send(Sck, "\r\n", 2, 0);
if((recv(Sck, Buffer, 512, 0))==0) //check the recv()
{
printf("A conexao foi desfeita\n");
exit(0);
}
else
{
if(strstr(Buffer, "250")==0)
{
printf("Erro inexperado.\n");
send(Sck, "quit\r\n", 6, 0); //Fecha a conexao
exit(0);
}
}
printf("%s\n", Buffer);
memset(Buffer, '\0', sizeof(Buffer));
/**********************************/
send(Sck, "DATA\r\n", 6, 0); //Diz ao servidor que eu estou pronto pra escrever o email
if((recv(Sck, Buffer, 512, 0))==0) //Verifica a resposta
{
printf("A conexao foi desfeita\n");
exit(0);
}
else
{
if(strstr(Buffer, "354")==0)
{
printf("Erro inexperado.\n");
send(Sck, "quit\r\n", 6, 0); //Fecha a conexao
exit(0);
}
}
printf("%s\n", Buffer);
memset(Buffer, '\0', sizeof(Buffer));
/**********************************/
/* thats the header of the mail
*
*/
send(Sck, "From: ", 6, 0);
send(Sck, From, strlen(From), 0);
send(Sck, "\r\n", 2, 0);
send(Sck, "To: ", 4, 0);
send(Sck, To, strlen(To), 0);
send(Sck, "\r\n", 2, 0);
send(Sck, "Subject: ", 9, 0);
send(Sck, Subject, strlen(Subject), 0);
send(Sck, "\r\n", 2, 0);
send(Sck, "MIME-Version: 1.0\r\n", 19, 0);
send(Sck, "Content-Type: multipart/alternative;\r\n", 38, 0);
send(Sck, " boundary=----=_Part_1255_4525121.1146192955226\r\n", 56, 0);
send(Sck, "\r\n", 2, 0);
send(Sck, "------=_Part_1255_4525121.1146192955226\r\n", 41, 0);
send(Sck, "Content-Type: text/plain; charset=ISO-8859-1; format=flowed\r\n", 61, 0);
send(Sck, "Content-Transfer-Encoding: quoted-printable\r\n", 45, 0);
send(Sck, "Content-Disposition: inline\r\n", 29, 0);
send(Sck, "\r\n", 2, 0);
send(Sck, Body, strlen(Body), 0);
send(Sck, "\r\n", 2, 0);
send(Sck, "------=_Part_1255_4525121.1146192955226--\r\n", 43, 0);
send(Sck, ".\r\n", 3, 0);
if((recv(Sck, Buffer, 512, 0))==0) //Verifica a resposta
{
printf("A conexao foi desfeita\n");
exit(0);
}
else
{
if(strstr(Buffer, "250")==0)
{
printf("Erro inexperado.\n");
send(Sck, "quit\r\n", 6, 0); //Fecha a conexao
exit(0);
}
}
printf("%s\n", Buffer);
send(Sck, "quit\r\n", 6, 0); //Fecha a conexao
memset(Buffer, '\0', sizeof(Buffer));
/**********************************/
}
return 0;
}
---------------------------------
Yahoo! doce lar. Faça do Yahoo! sua homepage.
---------------------------------
Novidade no Yahoo! Mail: receba alertas de novas mensagens no seu celular. Registre seu aparelho agora! |