cvs: php4 /win32 sendmail.c

From: Date: Mon, 10 Jul 2000 14:49:21 +0000
Subject: cvs: php4 /win32 sendmail.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-703@lists.php.net to get a copy of this message
jah Mon Jul 10 07:49:21 2000 EDT Modified files: /php4/win32 sendmail.c Log: - Another attempt to sync with PHP3 and handle multiple recipients. - Change all \'s to \r\n. - It's now PHP 4.0 WIN32 -mailer. # I'm unable to test, I haven't got Windows. Please check that it compiles. Index: php4/win32/sendmail.c diff -u php4/win32/sendmail.c:1.10 php4/win32/sendmail.c:1.11 --- php4/win32/sendmail.c:1.10 Tue Jun 27 11:41:44 2000 +++ php4/win32/sendmail.c Mon Jul 10 07:49:20 2000 @@ -60,7 +60,7 @@ char LocalHost[HOST_NAME_LEN]; #endif char seps[] = " ,\t\n"; -char *php_mailer = "PHP 3.0 WIN32"; +char *php_mailer = "PHP 4.0 WIN32"; char *get_header(char *h, char *headers); @@ -154,7 +154,7 @@ //********************************************************************/ void TSMClose() { - Post("QUIT\n"); + Post("QUIT\r\n"); Ack(); /* to guarantee that the cleanup is not made twice and compomise the rest of the application if sockets are used @@ -200,6 +200,7 @@ int res, i; char *p; + char *tempMailTo, *token, *pos1, *pos2; /* check for NULL parameters */ if (data == NULL) @@ -214,7 +215,7 @@ if (strchr(mailTo, '@') == NULL) return (BAD_MSG_DESTINATION); - sprintf(Buffer, "HELO %s\n", LocalHost); + sprintf(Buffer, "HELO %s\r\n", LocalHost); /* in the beggining of the dialog */ /* attempt reconnect if the first Post fail */ @@ -226,20 +227,47 @@ if ((res = Ack()) != SUCCESS) return (res); - sprintf(Buffer, "MAIL FROM:<%s>\n", RPath); + sprintf(Buffer, "MAIL FROM:<%s>\r\n", RPath); if ((res = Post(Buffer)) != SUCCESS) return (res); if ((res = Ack()) != SUCCESS) return (res); - sprintf(Buffer, "RCPT TO:<%s>\n", mailTo); - if ((res = Post(Buffer)) != SUCCESS) - return (res); - if ((res = Ack()) != SUCCESS) - return (res); + tempMailTo = estrdup(mailTo); + + /* Send mail to all rcpt's */ + token = strtok(tempMailTo, ","); + while(token != NULL) + { + sprintf(GLOBAL(Buffer), "RCPT TO:<%s>\r\n", token); + if ((res = Post(GLOBAL(Buffer))) != SUCCESS) + return (res); + if ((res = Ack()) != SUCCESS) + return (res); + token = strtok(NULL, ","); + } - if ((res = Post("DATA\n")) != SUCCESS) + /* Send mail to all Cc rcpt's */ + efree(tempMailTo); + if (headers && pos1 = strstr(headers, "Cc:")) { + pos2 = strstr(pos1, "\r\n"); + tempMailTo = estrndup(pos1, pos2-pos1); + + token = strtok(tempMailTo, ","); + while(token != NULL) + { + sprintf(Buffer, "RCPT TO:<%s>\r\n", token); + if ((res = Post(Buffer)) != SUCCESS) + return (res); + if ((res = Ack()) != SUCCESS) + return (res); + token = strtok(NULL, ","); + } + efree(tempMailTo); + } + + if ((res = Post("DATA\r\n")) != SUCCESS) return (res); if ((res = Ack()) != SUCCESS) return (res); @@ -335,7 +363,9 @@ p += sprintf(p, "From: %s\r\n", RPath); } p += sprintf(p, "Subject: %s\r\n", Subject); - p += sprintf(p, "To: %s\r\n", mailTo); + if(!xheaders || !strstr(xheaders, "To:")){ + p += sprintf(p, "To: %s\r\n", mailTo); + } if(xheaders){ p += sprintf(p, "%s\r\n", xheaders); }

« previous php.cvs (#703) next »