Commit 5470fef0 authored by Nickilo's avatar Nickilo

Vérification du retour du smtp

Pb après la commande DATA
parent d94d770f
......@@ -271,41 +271,68 @@ ZEND_FUNCTION(mail_php)
/****************************************************************************************************************************************/
/***************************************************************
** Lecture jusqu a une reponse 250 ou 334 + espace *******************
**************************************************************/
void readsmtp (SSL *ssl) {
char buf[PACKET_SIZE+1];
regex_t re;
int found=0;
int loopCount=0;
int status;
while (loopCount<10 && found==0) {
loopCount++;
if (sslReady==1) {
zend_printf("SSL");
int longueur=SSL_read(ssl, buf, PACKET_SIZE);
buf[longueur]='\0'; // Positionner le caractere de fin de chaine pour ne pas avoir les dechets du buffer
} else {
readn(to_server_socket,buf,PACKET_SIZE);
}
if (INI_BOOL("mail_php.enable_debug")) {
zend_printf(">");
zend_printf(buf);
}
if(regcomp(&re,"([0-9][0-9][0-9] )", REG_EXTENDED|REG_NOSUB) != 0) {
// C est une erreur
regfree(&re);
return;
}
status = regexec(&re, buf, (size_t) 0, NULL, 0);
if (status == 0) {
// Trouve
found=1;
regfree(&re);
return;
}
}
regfree(&re);
}
/***************************************************************
** sendsmtp : ecrire au serveur en attendant la reponse *******
**************************************************************/
void sendsmtp (char *msg,SSL *ssl) {
char buf[PACKET_SIZE+1];
regex_t re;
int retval = 0;
if (sslReady==1) {
if (INI_BOOL("mail_php.enable_debug")) {
zend_printf(msg);
}
SSL_write(ssl, msg, strlen(msg));
int longueur=SSL_read(ssl, buf, PACKET_SIZE);
buf[longueur]='\0'; // Positionner le caractere de fin de chaine pour ne pas avoir les dechets du buffer
readsmtp(ssl);
} else {
if (INI_BOOL("mail_php.enable_debug")) {
zend_printf(msg);
}
writen(to_server_socket,msg,strlen(msg));
readn(to_server_socket,buf,PACKET_SIZE);
readsmtp(ssl);
}
if (INI_BOOL("mail_php.enable_debug")) {
zend_printf(" ** Receive : ");
zend_printf(buf);
}
if(regcomp(&re,"(250|354)", REG_EXTENDED) != 0) {
return;
}
if((retval = regexec(&re, buf, 0, NULL, 0)) != 0) {
return;
}
regfree(&re);
return ;
}
/***************************************************************
** writesmtp : ecrire au serveur sans attendre la reponse *****
**************************************************************/
......@@ -441,7 +468,7 @@ void appli (char *login,char *pass, char *from, char *to, char *reply, char *sub
/* Loading a CA Certificate */
if (!SSL_CTX_load_verify_locations(ctx,"root.pem",0)) {
zend_printf("Error loadinf CA CERTIFICATE\n");
//zend_printf("Error loadinf CA CERTIFICATE\n");
}
/* Set a callback function (verify_callback) for peer certificate */
......@@ -499,7 +526,7 @@ void appli (char *login,char *pass, char *from, char *to, char *reply, char *sub
sendsmtp(">\r\n",ssl);
toone=strtok(NULL,";");
}
sendsmtp("DATA\n",ssl);
sendsmtp("DATA\r\n",ssl);
if (! INI_BOOL("mail_php.enable_headers")) {
// le from
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment