00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <config.h>
00021
00022 #include <stdio.h>
00023 #include <errno.h>
00024
00025 #ifdef HAVE_STRING_H
00026 #include <string.h>
00027 #endif
00028
00029 #include "protocol.h"
00030
00042 int check_smtp(Port_T p) {
00043
00044 int status;
00045 char buf[STRLEN];
00046 char msg[STRLEN];
00047 const char *command= "QUIT\r\n";
00048
00049 if ( sock_recv(p->socket, buf, sizeof(buf), 0) <= 0 ) {
00050 log("SMTP: error receiving data -- %s\n", STRERROR);
00051 return FALSE;
00052 }
00053
00054 chomp(buf);
00055
00056 sscanf(buf, "%d %s", &status, msg);
00057 if ( status != 220 ) {
00058 log("SMTP error: %s\n", buf);
00059 return FALSE;
00060 }
00061
00062 if ( sock_send(p->socket, command, strlen(command), 0) < 0 ) {
00063 log("SMTP: error sending data -- %s\n", STRERROR);
00064 return FALSE;
00065 }
00066
00067 if ( sock_recv(p->socket, buf, sizeof(buf), 0) <= 0 ) {
00068 log("SMTP: error receiving data -- %s\n", STRERROR);
00069 return FALSE;
00070 }
00071
00072 chomp(buf);
00073
00074 sscanf(buf, "%d %s", &status, msg);
00075 if ( status != 221 ) {
00076 log("SMTP error: %s\n", buf);
00077 return FALSE;
00078 }
00079
00080 return TRUE;
00081
00082 }
00083