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);
//********************************************************************/
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
int res, i;
char *p;
+ char *tempMailTo, *token, *pos1, *pos2;
/* check for NULL parameters */
if (data == NULL)
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 */
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);
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);
}