diff options
Diffstat (limited to 'win32/sendmail.c')
-rw-r--r-- | win32/sendmail.c | 103 |
1 files changed, 53 insertions, 50 deletions
diff --git a/win32/sendmail.c b/win32/sendmail.c index 659bc134a4..af337dab33 100644 --- a/win32/sendmail.c +++ b/win32/sendmail.c @@ -48,13 +48,13 @@ static char *months[] = #ifndef THREAD_SAFE char Buffer[MAIL_BUFFER_SIZE]; -// socket related data +/* socket related data */ SOCKET sc; WSADATA Data; struct hostent *adr; SOCKADDR_IN sock_in; int WinsockStarted; -// values set by the constructor +/* values set by the constructor */ char *AppName; char MailHost[HOST_NAME_LEN]; char LocalHost[HOST_NAME_LEN]; @@ -64,7 +64,7 @@ char *php_mailer = "PHP 3.0 WIN32"; char *get_header(char *h, char *headers); -// Error messages +/* Error messages */ static char *ErrorMessages[] = { {"Success"}, @@ -91,7 +91,7 @@ static char *ErrorMessages[] = -//******************************************************************** +/********************************************************************* // Name: TSendMail // Input: 1) host: Name of the mail host where the SMTP server resides // max accepted length of name = 256 @@ -103,7 +103,7 @@ static char *ErrorMessages[] = // SUCCESS otherwise. // // See SendText() for additional args! -//******************************************************************** +//********************************************************************/ int TSendMail(char *host, int *error, char *headers, char *Subject, char *mailTo, char *data) { @@ -128,7 +128,7 @@ int TSendMail(char *host, int *error, return 19; } - // attempt to connect with mail host + /* attempt to connect with mail host */ *error = MailConnect(); if (*error != 0) { if(RPath)efree(RPath); @@ -144,32 +144,33 @@ int TSendMail(char *host, int *error, } } -//******************************************************************** +/'******************************************************************** // Name: TSendMail::~TSendMail // Input: // Output: // Description: DESTRUCTOR // Author/Date: jcar 20/9/96 // History: -//******************************************************************** +//********************************************************************/ void TSMClose() { Post("QUIT\n"); Ack(); - // to guarantee that the cleanup is not made twice and - // compomise the rest of the application if sockets are used - // elesewhere + /* to guarantee that the cleanup is not made twice and + compomise the rest of the application if sockets are used + elesewhere + */ } -//******************************************************************** +/********************************************************************* // Name: char *GetSMErrorText // Input: Error index returned by the menber functions // Output: pointer to a string containing the error description // Description: // Author/Date: jcar 20/9/96 // History: -//******************************************************************** +//*******************************************************************/ char *GetSMErrorText(int index) { @@ -180,7 +181,7 @@ char *GetSMErrorText(int index) } -//******************************************************************** +/********************************************************************* // Name: TSendText // Input: 1) RPath: return path of the message // Is used to fill the "Return-Path" and the @@ -193,14 +194,14 @@ char *GetSMErrorText(int index) // Description: // Author/Date: jcar 20/9/96 // History: -//******************************************************************** +//*******************************************************************/ int SendText(char *RPath, char *Subject, char *mailTo, char *data, char *headers) { int res, i; char *p; - // check for NULL parameters + /* check for NULL parameters */ if (data == NULL) return (BAD_MSG_CONTENTS); if (mailTo == NULL) @@ -208,15 +209,15 @@ int SendText(char *RPath, char *Subject, char *mailTo, char *data, char *headers if (RPath == NULL) return (BAD_MSG_RPATH); - // simple checks for the mailto address - // have ampersand ? + /* simple checks for the mailto address */ + /* have ampersand ? */ if (strchr(mailTo, '@') == NULL) return (BAD_MSG_DESTINATION); sprintf(Buffer, "HELO %s\n", LocalHost); - // in the beggining of the dialog - // attempt reconnect if the first Post fail + /* in the beggining of the dialog */ + /* attempt reconnect if the first Post fail */ if ((res = Post(Buffer)) != SUCCESS) { MailConnect(); if ((res = Post(Buffer)) != SUCCESS) @@ -244,7 +245,7 @@ int SendText(char *RPath, char *Subject, char *mailTo, char *data, char *headers return (res); - // send message header + /* send message header */ if (Subject == NULL) res = PostHeader(RPath, "No Subject", mailTo, headers); else @@ -253,7 +254,7 @@ int SendText(char *RPath, char *Subject, char *mailTo, char *data, char *headers return (res); - // send message contents in 1024 chunks + /* send message contents in 1024 chunks */ if (strlen(data) <= 1024) { if ((res = Post(data)) != SUCCESS) return (res); @@ -267,18 +268,18 @@ int SendText(char *RPath, char *Subject, char *mailTo, char *data, char *headers else i = strlen(p); - // put next chunk in buffer + /* put next chunk in buffer */ strncpy(Buffer, p, i); Buffer[i] = '\0'; p += i; - // send chunk + /* send chunk */ if ((res = Post(Buffer)) != SUCCESS) return (res); } } - //send termination dot + /*send termination dot */ if ((res = Post("\r\n.\r\n")) != SUCCESS) return (res); if ((res = Ack()) != SUCCESS) @@ -289,7 +290,7 @@ int SendText(char *RPath, char *Subject, char *mailTo, char *data, char *headers -//******************************************************************** +/********************************************************************* // Name: PostHeader // Input: 1) return path // 2) Subject @@ -299,12 +300,12 @@ int SendText(char *RPath, char *Subject, char *mailTo, char *data, char *headers // Description: // Author/Date: jcar 20/9/96 // History: -//******************************************************************** +//********************************************************************/ int PostHeader(char *RPath, char *Subject, char *mailTo, char *xheaders) { - // Print message header according to RFC 822 - // Return-path, Received, Date, From, Subject, Sender, To, cc + /* Print message header according to RFC 822 */ + /* Return-path, Received, Date, From, Subject, Sender, To, cc */ time_t tNow = time(NULL); struct tm *tm = localtime(&tNow); @@ -350,34 +351,36 @@ int PostHeader(char *RPath, char *Subject, char *mailTo, char *xheaders) -//******************************************************************** +/********************************************************************* // Name: MailConnect // Input: None // Output: None // Description: Connect to the mail host and receive the welcome message. // Author/Date: jcar 20/9/96 // History: -//******************************************************************** +//********************************************************************/ int MailConnect() { int res; - // Create Socket + /* Create Socket */ if ((sc = socket(PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) return (FAILED_TO_OBTAIN_SOCKET_HANDLE); - // Get our own host name + /* Get our own host name */ if (gethostname(LocalHost, HOST_NAME_LEN)) return (FAILED_TO_GET_HOSTNAME); - // Resolve the servers IP - //if (!isdigit(MailHost[0])||!gethostbyname(MailHost)) - //{ - // return (FAILED_TO_RESOLVE_HOST); - //} + /* Resolve the servers IP */ + /* + if (!isdigit(MailHost[0])||!gethostbyname(MailHost)) + { + return (FAILED_TO_RESOLVE_HOST); + } + */ - // Connect to server + /* Connect to server */ sock_in.sin_family = AF_INET; sock_in.sin_port = htons(25); sock_in.sin_addr.S_un.S_addr = GetAddr(MailHost); @@ -385,7 +388,7 @@ int MailConnect() if (connect(sc, (LPSOCKADDR) & sock_in, sizeof(sock_in))) return (FAILED_TO_CONNECT); - // receive Server welcome message + /* receive Server welcome message */ res = Ack(); return (res); } @@ -395,14 +398,14 @@ int MailConnect() -//******************************************************************** +/********************************************************************* // Name: Post // Input: // Output: // Description: // Author/Date: jcar 20/9/96 // History: -//******************************************************************** +//********************************************************************/ int Post(LPCSTR msg) { int len = strlen(msg); @@ -420,7 +423,7 @@ int Post(LPCSTR msg) -//******************************************************************** +/********************************************************************* // Name: Ack // Input: // Output: @@ -429,7 +432,7 @@ int Post(LPCSTR msg) // last command was successful. // Author/Date: jcar 20/9/96 // History: -//******************************************************************** +//********************************************************************/ int Ack() { static char *buf; @@ -448,13 +451,13 @@ int Ack() Received += rlen; buf[Received] = 0; - //err_msg fprintf(stderr,"Received: (%d bytes) %s", rlen, buf + Index); + /*err_msg fprintf(stderr,"Received: (%d bytes) %s", rlen, buf + Index); */ - // Check for newline + /* Check for newline */ Index += rlen; if ((buf[Received - 2] != '\r') || (buf[Received - 1] != '\n')) - // err_msg fprintf(stderr,"Incomplete server message. Awaiting CRLF\n"); - goto again; // Incomplete data. Line must be terminated by CRLF + /* err_msg fprintf(stderr,"Incomplete server message. Awaiting CRLF\n"); */ + goto again; /* Incomplete data. Line must be terminated by CRLF */ if (buf[0] > '3') return (SMTP_SERVER_ERROR); @@ -463,7 +466,7 @@ int Ack() } -//******************************************************************** +/********************************************************************* // Name: unsigned long GetAddr (LPSTR szHost) // Input: // Output: @@ -474,7 +477,7 @@ int Ack() // WARNING: gethostbyname() is a blocking function // Author/Date: jcar 20/9/96 // History: -//******************************************************************** +//********************************************************************/ unsigned long GetAddr(LPSTR szHost) { LPHOSTENT lpstHost; |