| version 1.5, 2002/10/21 13:06:27 |
version 1.6, 2002/10/21 13:38:44 |
| Line 63 int smtp_connect(const char* zServer, in |
|
| Line 63 int smtp_connect(const char* zServer, in |
|
| with the server */ |
with the server */ |
| |
|
| #ifdef __SMTP_DEBUG |
#ifdef __SMTP_DEBUG |
| printf("libsmtp : smtp_connect : Server is \"%s\", port %i\n", |
printf("libsmtp: smtp_connect: Server is \"%s\", port %i\n", |
| zServer,nPort); |
zServer,nPort); |
| #endif /* __SMTP_DEBUG */ |
#endif /* __SMTP_DEBUG */ |
| |
|
| Line 74 int smtp_connect(const char* zServer, in |
|
| Line 74 int smtp_connect(const char* zServer, in |
|
| return(-SMTP_UNKNOWN_SERVER); |
return(-SMTP_UNKNOWN_SERVER); |
| |
|
| #ifdef __SMTP_DEBUG |
#ifdef __SMTP_DEBUG |
| printf("libsmtp : smtp_connect : IP address %s\n", |
printf("libsmtp: smtp_connect: IP address %s\n", |
| inet_ntoa(*((struct in_addr *)sServer->h_addr))); |
inet_ntoa(*((struct in_addr *)sServer->h_addr))); |
| #endif /* __SMTP_DEBUG */ |
#endif /* __SMTP_DEBUG */ |
| |
|
| Line 92 int smtp_connect(const char* zServer, in |
|
| Line 92 int smtp_connect(const char* zServer, in |
|
| &(sSocketAddr.sin_addr))==0) |
&(sSocketAddr.sin_addr))==0) |
| { |
{ |
| #ifdef __SMTP_DEBUG |
#ifdef __SMTP_DEBUG |
| printf("libsmtp : smtp_connect : Connect failed at inet_ntoa()\n"); |
printf("libsmtp: smtp_connect: Connect failed at inet_ntoa()\n"); |
| #endif /* __SMTP_DEBUG */ |
#endif /* __SMTP_DEBUG */ |
| return(-SMTP_CONNECT_FAILED); |
return(-SMTP_CONNECT_FAILED); |
| } |
} |
| Line 106 int smtp_connect(const char* zServer, in |
|
| Line 106 int smtp_connect(const char* zServer, in |
|
| sizeof(struct sockaddr))==-1) |
sizeof(struct sockaddr))==-1) |
| { |
{ |
| #ifdef __SMTP_DEBUG |
#ifdef __SMTP_DEBUG |
| printf("libsmtp : smtp_connect : Connect failed at connect()\n"); |
printf("libsmtp: smtp_connect: Connect failed at connect()\n"); |
| #endif /* __SMTP_DEBUG */ |
#endif /* __SMTP_DEBUG */ |
| return(-SMTP_CONNECT_FAILED); |
return(-SMTP_CONNECT_FAILED); |
| } |
} |
| Line 117 int smtp_connect(const char* zServer, in |
|
| Line 117 int smtp_connect(const char* zServer, in |
|
| return(-SMTP_TIMED_OUT); |
return(-SMTP_TIMED_OUT); |
| |
|
| #ifdef __SMTP_DEBUG |
#ifdef __SMTP_DEBUG |
| printf("libsmtp : smtp_connect : Connected\n"); |
printf("libsmtp: smtp_connect: Connected\n"); |
| #endif /* __SMTP_DEBUG */ |
#endif /* __SMTP_DEBUG */ |
| |
|
| /* We should now have a socket connection to the server, |
/* We should now have a socket connection to the server, |
| Line 128 int smtp_connect(const char* zServer, in |
|
| Line 128 int smtp_connect(const char* zServer, in |
|
| if(nBytesRecv<3) |
if(nBytesRecv<3) |
| { |
{ |
| #ifdef __SMTP_DEBUG |
#ifdef __SMTP_DEBUG |
| printf("libsmtp : smtp_connect : Server did not respond correctly!\n"); |
printf("libsmtp: smtp_connect: Server did not respond correctly!\n"); |
| #endif /* __SMTP_DEBUG */ |
#endif /* __SMTP_DEBUG */ |
| return(-SMTP_CONNECT_FAILED); |
return(-SMTP_CONNECT_FAILED); |
| } |
} |
| Line 139 int smtp_connect(const char* zServer, in |
|
| Line 139 int smtp_connect(const char* zServer, in |
|
| if(strcmp(nRecvBuf,"220")!=0) |
if(strcmp(nRecvBuf,"220")!=0) |
| { |
{ |
| #ifdef __SMTP_DEBUG |
#ifdef __SMTP_DEBUG |
| printf("libsmtp : smtp_connect : Server responded %s\n", |
printf("libsmtp: smtp_connect: Server responded %s\n", |
| nRecvBuf); |
nRecvBuf); |
| #endif /* __SMTP_DEBUG */ |
#endif /* __SMTP_DEBUG */ |
| return(-SMTP_CONNECT_FAILED); |
return(-SMTP_CONNECT_FAILED); |
| Line 160 int smtp_connect(const char* zServer, in |
|
| Line 160 int smtp_connect(const char* zServer, in |
|
| nHeloMsg=strcat(nHeloMsg,"\r\n\0"); |
nHeloMsg=strcat(nHeloMsg,"\r\n\0"); |
| |
|
| #ifdef __SMTP_DEBUG |
#ifdef __SMTP_DEBUG |
| printf("libsmtp : smtp_connectt : HELO message is %s\n",nHeloMsg); |
printf("libsmtp: smtp_connectt: HELO message is %s\n",nHeloMsg); |
| #endif /* __SMTP_DEBUG */ |
#endif /* __SMTP_DEBUG */ |
| |
|
| /* Now send the HELO line & wait for the response */ |
/* Now send the HELO line & wait for the response */ |
| |
|
| #ifdef __SMTP_DEBUG |
#ifdef __SMTP_DEBUG |
| printf("libsmtp : smtp_connect : Sending HELO\n"); |
printf("libsmtp: smtp_connect: Sending HELO\n"); |
| #endif /* __SMTP_DEBUG */ |
#endif /* __SMTP_DEBUG */ |
| |
|
| nBytesSend=send(__smtpGlobalSocket,nHeloMsg,strlen(nHeloMsg),0); |
nBytesSend=send(__smtpGlobalSocket,nHeloMsg,strlen(nHeloMsg),0); |
| |
|
| if(nBytesSend!=strlen(nHeloMsg)) |
if(nBytesSend!=strlen(nHeloMsg)) |
| #ifdef __SMTP_DEBUG |
#ifdef __SMTP_DEBUG |
| printf("libsmtp : smtp_connect : Didn't send entire HELO\n"); |
printf("libsmtp: smtp_connect: Didn't send entire HELO\n"); |
| #endif /* __SMTP_DEBUG */ |
#endif /* __SMTP_DEBUG */ |
| |
|
| /* Get server response, which should be 250 if we're good to go */ |
/* Get server response, which should be 250 if we're good to go */ |
| Line 183 int smtp_connect(const char* zServer, in |
|
| Line 183 int smtp_connect(const char* zServer, in |
|
| nBytesRecv=recv(__smtpGlobalSocket,(void*)&nRecvBuf,3,0); |
nBytesRecv=recv(__smtpGlobalSocket,(void*)&nRecvBuf,3,0); |
| if(nBytesRecv<3) |
if(nBytesRecv<3) |
| #ifdef __SMTP_DEBUG |
#ifdef __SMTP_DEBUG |
| printf("libsmtp : smtp_connect : Recieved less than 3 bytes\n"); |
printf("libsmtp: smtp_connect: Recieved less than 3 bytes\n"); |
| #endif /* __SMTP_DEBUG */ |
#endif /* __SMTP_DEBUG */ |
| |
|
| /* Clear the timeout alarm & see if we timedout */ |
/* Clear the timeout alarm & see if we timedout */ |
| Line 197 int smtp_connect(const char* zServer, in |
|
| Line 197 int smtp_connect(const char* zServer, in |
|
| if(strcmp(nRecvBuf,"250")!=0) |
if(strcmp(nRecvBuf,"250")!=0) |
| { |
{ |
| #ifdef __SMTP_DEBUG |
#ifdef __SMTP_DEBUG |
| printf("libsmtp : smtp_connect : HELO failed\n"); |
printf("libsmtp: smtp_connect: HELO failed\n"); |
| printf("libsmtp : smtp_connect : Server responded %s\n", |
printf("libsmtp: smtp_connect: Server responded %s\n", |
| nRecvBuf); |
nRecvBuf); |
| #endif /* __SMTP_DEBUG */ |
#endif /* __SMTP_DEBUG */ |
| return(-SMTP_CONNECT_FAILED); |
return(-SMTP_CONNECT_FAILED); |
| Line 207 int smtp_connect(const char* zServer, in |
|
| Line 207 int smtp_connect(const char* zServer, in |
|
| /* The server is ready to recieve email from us */ |
/* The server is ready to recieve email from us */ |
| |
|
| #ifdef __SMTP_DEBUG |
#ifdef __SMTP_DEBUG |
| printf("libsmtp : smtp_connect : Ready to send\n"); |
printf("libsmtp: smtp_connect: Ready to send\n"); |
| #endif /* __SMTP_DEBUG */ |
#endif /* __SMTP_DEBUG */ |
| |
|
| /* Clear out the rest of the buffer */ |
/* Clear out the rest of the buffer */ |
| Line 249 int smtp_sendmail(const char* zTo, const |
|
| Line 249 int smtp_sendmail(const char* zTo, const |
|
| nBytesRecv=recv(__smtpGlobalSocket,(void*)&nRecvBuf,3,0); |
nBytesRecv=recv(__smtpGlobalSocket,(void*)&nRecvBuf,3,0); |
| if(nBytesRecv<3) |
if(nBytesRecv<3) |
| #ifdef __SMTP_DEBUG |
#ifdef __SMTP_DEBUG |
| printf("libsmtp : smtp_sendmail : Recieved less than 3 bytes\n"); |
printf("libsmtp: smtp_sendmail: Recieved less than 3 bytes\n"); |
| #endif /* __SMTP_DEBUG */ |
#endif /* __SMTP_DEBUG */ |
| |
|
| /* Clear the timeout alarm & see if we timedout */ |
/* Clear the timeout alarm & see if we timedout */ |
| Line 263 int smtp_sendmail(const char* zTo, const |
|
| Line 263 int smtp_sendmail(const char* zTo, const |
|
| if(strcmp(nRecvBuf,"250")!=0) |
if(strcmp(nRecvBuf,"250")!=0) |
| { |
{ |
| #ifdef __SMTP_DEBUG |
#ifdef __SMTP_DEBUG |
| printf("libsmtp : smtp_sendmail : MAIL FROM: failed\n"); |
printf("libsmtp: smtp_sendmail: MAIL FROM: failed\n"); |
| printf("libsmtp : smtp_sendmail : Server responded %s\n", nRecvBuf); |
printf("libsmtp: smtp_sendmail: Server responded %s\n", nRecvBuf); |
| #endif /* __SMTP_DEBUG */ |
#endif /* __SMTP_DEBUG */ |
| return(-SMTP_INVALID_FROM); |
return(-SMTP_INVALID_FROM); |
| } |
} |
| Line 295 int smtp_sendmail(const char* zTo, const |
|
| Line 295 int smtp_sendmail(const char* zTo, const |
|
| nBytesRecv=recv(__smtpGlobalSocket,(void*)&nRecvBuf,3,0); |
nBytesRecv=recv(__smtpGlobalSocket,(void*)&nRecvBuf,3,0); |
| if(nBytesRecv<3) |
if(nBytesRecv<3) |
| #ifdef __SMTP_DEBUG |
#ifdef __SMTP_DEBUG |
| printf("libsmtp : smtp_sendmail : Recieved less than 3 bytes\n"); |
printf("libsmtp: smtp_sendmail: Recieved less than 3 bytes\n"); |
| #endif /* __SMTP_DEBUG */ |
#endif /* __SMTP_DEBUG */ |
| |
|
| /* Clear the timeout alarm & see if we timedout */ |
/* Clear the timeout alarm & see if we timedout */ |
| Line 309 int smtp_sendmail(const char* zTo, const |
|
| Line 309 int smtp_sendmail(const char* zTo, const |
|
| if(strcmp(nRecvBuf,"250")!=0) |
if(strcmp(nRecvBuf,"250")!=0) |
| { |
{ |
| #ifdef __SMTP_DEBUG |
#ifdef __SMTP_DEBUG |
| printf("libsmtp : smtp_sendmail : RCPT TO: failed\n"); |
printf("libsmtp: smtp_sendmail: RCPT TO: failed\n"); |
| printf("libsmtp : smtp_sendmail : Server responded %s\n", |
printf("libsmtp: smtp_sendmail: Server responded %s\n", |
| nRecvBuf); |
nRecvBuf); |
| #endif /* __SMTP_DEBUG */ |
#endif /* __SMTP_DEBUG */ |
| return(-SMTP_INVALID_TO); |
return(-SMTP_INVALID_TO); |
| Line 330 int smtp_sendmail(const char* zTo, const |
|
| Line 330 int smtp_sendmail(const char* zTo, const |
|
| nBytesRecv=recv(__smtpGlobalSocket,(void*)&nRecvBuf,3,0); |
nBytesRecv=recv(__smtpGlobalSocket,(void*)&nRecvBuf,3,0); |
| if(nBytesRecv<3) |
if(nBytesRecv<3) |
| #ifdef __SMTP_DEBUG |
#ifdef __SMTP_DEBUG |
| printf("libsmtp : smtp_sendmail : Recieved less than 3 bytes\n"); |
printf("libsmtp: smtp_sendmail: Recieved less than 3 bytes\n"); |
| #endif /* __SMTP_DEBUG */ |
#endif /* __SMTP_DEBUG */ |
| |
|
| /* Clear the timeout alarm & see if we timedout */ |
/* Clear the timeout alarm & see if we timedout */ |
| Line 344 int smtp_sendmail(const char* zTo, const |
|
| Line 344 int smtp_sendmail(const char* zTo, const |
|
| if(strcmp(nRecvBuf,"354")!=0) |
if(strcmp(nRecvBuf,"354")!=0) |
| { |
{ |
| #ifdef __SMTP_DEBUG |
#ifdef __SMTP_DEBUG |
| printf("libsmtp : smtp_sendmail : DATA failed\n"); |
printf("libsmtp: smtp_sendmail: DATA failed\n"); |
| printf("libsmtp : smtp_sendmail : Server responded %s\n", nRecvBuf); |
printf("libsmtp: smtp_sendmail: Server responded %s\n", nRecvBuf); |
| #endif /* __SMTP_DEBUG */ |
#endif /* __SMTP_DEBUG */ |
| return(-SMTP_SEND_FAILED); |
return(-SMTP_SEND_FAILED); |
| } |
} |
| Line 360 int smtp_sendmail(const char* zTo, const |
|
| Line 360 int smtp_sendmail(const char* zTo, const |
|
| if(nBytesSend<strlen(zBody)) |
if(nBytesSend<strlen(zBody)) |
| { |
{ |
| #ifdef __SMTP_DEBUG |
#ifdef __SMTP_DEBUG |
| printf("libsmtp : smtp_sendmail : " |
printf("libsmtp: smtp_sendmail: " |
| "Failed to send entire message body\n"); |
"Failed to send entire message body\n"); |
| #endif /* __SMTP_DEBUG */ |
#endif /* __SMTP_DEBUG */ |
| return(-SMTP_SEND_FAILED); |
return(-SMTP_SEND_FAILED); |
| Line 376 int smtp_sendmail(const char* zTo, const |
|
| Line 376 int smtp_sendmail(const char* zTo, const |
|
| nBytesRecv=recv(__smtpGlobalSocket,(void*)&nRecvBuf,3,0); |
nBytesRecv=recv(__smtpGlobalSocket,(void*)&nRecvBuf,3,0); |
| if(nBytesRecv<3) |
if(nBytesRecv<3) |
| #ifdef __SMTP_DEBUG |
#ifdef __SMTP_DEBUG |
| printf("libsmtp : smtp_sendmail : Recieved less than 3 bytes\n"); |
printf("libsmtp: smtp_sendmail: Recieved less than 3 bytes\n"); |
| #endif /* __SMTP_DEBUG */ |
#endif /* __SMTP_DEBUG */ |
| |
|
| /* Clear the timeout alarm & see if we timedout */ |
/* Clear the timeout alarm & see if we timedout */ |
| Line 390 int smtp_sendmail(const char* zTo, const |
|
| Line 390 int smtp_sendmail(const char* zTo, const |
|
| if(strcmp(nRecvBuf,"250")!=0) |
if(strcmp(nRecvBuf,"250")!=0) |
| { |
{ |
| #ifdef __SMTP_DEBUG |
#ifdef __SMTP_DEBUG |
| printf("libsmtp : smtp_sendmail : " |
printf("libsmtp: smtp_sendmail: " |
| "Send failed after message send completed\n"); |
"Send failed after message send completed\n"); |
| printf("libsmtp : smtp_sendmail : Server responded %s\n", |
printf("libsmtp: smtp_sendmail: Server responded %s\n", |
| nRecvBuf); |
nRecvBuf); |
| #endif /* __SMTP_DEBUG */ |
#endif /* __SMTP_DEBUG */ |
| return(-SMTP_SEND_FAILED); |
return(-SMTP_SEND_FAILED); |
| Line 424 int smtp_disconnect(void) |
|
| Line 424 int smtp_disconnect(void) |
|
| nBytesRecv=recv(__smtpGlobalSocket,(void*)&nRecvBuf,3,0); |
nBytesRecv=recv(__smtpGlobalSocket,(void*)&nRecvBuf,3,0); |
| if(nBytesRecv<3) |
if(nBytesRecv<3) |
| #ifdef __SMTP_DEBUG |
#ifdef __SMTP_DEBUG |
| printf("libsmtp : smtp_disconnect : Recieved less than 3 bytes\n"); |
printf("libsmtp: smtp_disconnect: Recieved less than 3 bytes\n"); |
| #endif /* __SMTP_DEBUG */ |
#endif /* __SMTP_DEBUG */ |
| |
|
| /* Clear the timeout alarm & see if we timedout */ |
/* Clear the timeout alarm & see if we timedout */ |
| Line 438 int smtp_disconnect(void) |
|
| Line 438 int smtp_disconnect(void) |
|
| if(strcmp(nRecvBuf,"221")!=0) |
if(strcmp(nRecvBuf,"221")!=0) |
| { |
{ |
| #ifdef __SMTP_DEBUG |
#ifdef __SMTP_DEBUG |
| printf("libsmtp : smtp_disconnect : QUIT failed\n"); |
printf("libsmtp: smtp_disconnect: QUIT failed\n"); |
| printf("libsmtp : smtp_disconnect : Server responded %s\n", |
printf("libsmtp: smtp_disconnect: Server responded %s\n", |
| nRecvBuf); |
nRecvBuf); |
| #endif /* __SMTP_DEBUG */ |
#endif /* __SMTP_DEBUG */ |
| return(-SMTP_DISCONNECT_FAILED); |
return(-SMTP_DISCONNECT_FAILED); |
| Line 494 void smtp_alarm(int unused) |
|
| Line 494 void smtp_alarm(int unused) |
|
| /* Callback function for alarm() */ |
/* Callback function for alarm() */ |
| { |
{ |
| #ifdef __SMTP_DEBUG |
#ifdef __SMTP_DEBUG |
| printf("libsmtp : smtp_alarm : Timed out!\n"); |
printf("libsmtp: smtp_alarm: Timed out!\n"); |
| #endif |
#endif |
| |
|
| __smtpTimedOut=1; |
__smtpTimedOut=1; |