[PHP-CVS] cvs: php-src /win32 sendmail.c

2009-06-30 Thread Kalle Sommer Nielsen
kalle   Tue Jun 30 11:36:58 2009 UTC

  Modified files:  
/php-src/win32  sendmail.c 
  Log:
  Fixed bug #38091 (Mail() does not use FQDN when sending SMTP helo)
  
http://cvs.php.net/viewvc.cgi/php-src/win32/sendmail.c?r1=1.70r2=1.71diff_format=u
Index: php-src/win32/sendmail.c
diff -u php-src/win32/sendmail.c:1.70 php-src/win32/sendmail.c:1.71
--- php-src/win32/sendmail.c:1.70   Fri Jul  6 23:06:51 2007
+++ php-src/win32/sendmail.cTue Jun 30 11:36:58 2009
@@ -17,7 +17,7 @@
  *
  */
 
-/* $Id: sendmail.c,v 1.70 2007/07/06 23:06:51 dmitry Exp $ */
+/* $Id: sendmail.c,v 1.71 2009/06/30 11:36:58 kalle Exp $ */
 
 #include php.h   /*php specific */
 #include stdio.h
@@ -37,6 +37,7 @@
 #endif /* NETWARE */
 #include sendmail.h
 #include php_ini.h
+#include inet.h
 
 #if HAVE_PCRE || HAVE_BUNDLED_PCRE
 #include ext/pcre/php_pcre.h
@@ -765,16 +766,52 @@
 static int MailConnect()
 {
 
-   int res;
+   int res, namelen;
short portnum;
+   struct hostent *ent;
+   IN_ADDR addr;
+#ifdef HAVE_IPV6
+   IN6_ADDR addr6;
+#endif
 
/* Create Socket */
-   if ((sc = socket(PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
+   if ((sc = socket(PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) {
return (FAILED_TO_OBTAIN_SOCKET_HANDLE);
+   }
 
/* Get our own host name */
-   if (gethostname(LocalHost, HOST_NAME_LEN))
+   if (gethostname(LocalHost, HOST_NAME_LEN)) {
+   return (FAILED_TO_GET_HOSTNAME);
+   }
+
+   ent = gethostbyname(LocalHost);
+
+   if (!ent) {
return (FAILED_TO_GET_HOSTNAME);
+   }
+
+   namelen = strlen(ent-h_name);
+
+#ifdef HAVE_IPV6
+   if (inet_pton(AF_INET, ent-h_name, addr) == 1 || inet_pton(AF_INET6, 
ent-h_name, addr6) == 1)
+#else
+   if (inet_pton(AF_INET, ent-h_name, addr) == 1)
+#endif
+   {
+   if (namelen + 2 = HOST_NAME_LEN) {
+   return (FAILED_TO_GET_HOSTNAME);
+   }
+
+   strcpy(LocalHost, [);
+   strcpy(LocalHost + 1, ent-h_name);
+   strcpy(LocalHost + namelen + 1, ]);
+   } else {
+   if (namelen = HOST_NAME_LEN) {
+   return (FAILED_TO_GET_HOSTNAME);
+   }
+
+   strcpy(LocalHost, ent-h_name);
+   }
 
/* Resolve the servers IP */
/*
@@ -794,8 +831,9 @@
sock_in.sin_port = htons(portnum);
sock_in.sin_addr.S_un.S_addr = GetAddr(MailHost);
 
-   if (connect(sc, (LPSOCKADDR)  sock_in, sizeof(sock_in)))
+   if (connect(sc, (LPSOCKADDR)  sock_in, sizeof(sock_in))) {
return (FAILED_TO_CONNECT);
+   }
 
/* receive Server welcome message */
res = Ack(NULL);



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /win32 sendmail.c /win32/build template.rc

2006-02-08 Thread Johannes Schl
johannesWed Feb  8 21:03:00 2006 UTC

  Modified files:  
/php-src/win32  sendmail.c 
/php-src/win32/buildtemplate.rc 
  Log:
  - It's 2006 and PHP 6
  
http://cvs.php.net/viewcvs.cgi/php-src/win32/sendmail.c?r1=1.66r2=1.67diff_format=u
Index: php-src/win32/sendmail.c
diff -u php-src/win32/sendmail.c:1.66 php-src/win32/sendmail.c:1.67
--- php-src/win32/sendmail.c:1.66   Fri Jan  6 02:04:22 2006
+++ php-src/win32/sendmail.cWed Feb  8 21:03:00 2006
@@ -17,7 +17,7 @@
  *
  */
 
-/* $Id: sendmail.c,v 1.66 2006/01/06 02:04:22 sniper Exp $ */
+/* $Id: sendmail.c,v 1.67 2006/02/08 21:03:00 johannes Exp $ */
 
 #include php.h   /*php specific */
 #include stdio.h
@@ -85,9 +85,9 @@
 #endif
 char seps[] =  ,\t\n;
 #ifndef NETWARE
-char *php_mailer = PHP 4 WIN32;
+char *php_mailer = PHP 6 WIN32;
 #else
-char *php_mailer = PHP 4 NetWare;
+char *php_mailer = PHP 6 NetWare;
 #endif /* NETWARE */
 
 /* Error messages */
http://cvs.php.net/viewcvs.cgi/php-src/win32/build/template.rc?r1=1.7r2=1.8diff_format=u
Index: php-src/win32/build/template.rc
diff -u php-src/win32/build/template.rc:1.7 php-src/win32/build/template.rc:1.8
--- php-src/win32/build/template.rc:1.7 Wed Aug  3 14:08:58 2005
+++ php-src/win32/build/template.rc Wed Feb  8 21:03:00 2006
@@ -1,5 +1,5 @@
 /* This is a template RC file.
- * $Id: template.rc,v 1.7 2005/08/03 14:08:58 sniper Exp $
+ * $Id: template.rc,v 1.8 2006/02/08 21:03:00 johannes Exp $
  * Do not edit with MSVC */
 #ifdef APSTUDIO_INVOKED
 # error dont edit with MSVC
@@ -47,7 +47,7 @@
 VALUE FileDescription, FILE_DESCRIPTION \0
 VALUE FileVersion, STRVER4(PHP_MAJOR_VERSION, PHP_MINOR_VERSION, 
PHP_RELEASE_VERSION, PHP_RELEASE_VERSION)
 VALUE InternalName, FILE_NAME \0
-VALUE LegalCopyright, Copyright © 1997-2005 The PHP Group\0
+VALUE LegalCopyright, Copyright  1997-2006 The PHP Group\0
 VALUE LegalTrademarks, PHP\0
 VALUE OriginalFilename, FILE_NAME \0
 VALUE PrivateBuild, \0

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /win32 sendmail.c

2006-01-05 Thread Jani Taskinen
sniper  Fri Jan  6 02:04:22 2006 UTC

  Modified files:  
/php-src/win32  sendmail.c 
  Log:
  - Cleanups:
* unify the address handling to always strip leading whitespace
* ws fixes
  
  
http://cvs.php.net/viewcvs.cgi/php-src/win32/sendmail.c?r1=1.65r2=1.66diff_format=u
Index: php-src/win32/sendmail.c
diff -u php-src/win32/sendmail.c:1.65 php-src/win32/sendmail.c:1.66
--- php-src/win32/sendmail.c:1.65   Sun Aug  7 22:06:29 2005
+++ php-src/win32/sendmail.cFri Jan  6 02:04:22 2006
@@ -17,7 +17,7 @@
  *
  */
 
-/* $Id: sendmail.c,v 1.65 2005/08/07 22:06:29 sniper Exp $ */
+/* $Id: sendmail.c,v 1.66 2006/01/06 02:04:22 sniper Exp $ */
 
 #include php.h   /*php specific */
 #include stdio.h
@@ -42,8 +42,8 @@
 #include ext/pcre/php_pcre.h
 #endif
 
-#include ext/standard/php_string.h
-#include ext/date/php_date.h
+#include ext/standard/php_string.h
+#include ext/date/php_date.h
 
 /*enum
{
@@ -269,7 +269,7 @@
if (NULL == (pos2 = strstr(pos1, \r\n))) {
RPath = estrndup(pos1, strlen(pos1));
} else {
-   RPath = estrndup(pos1, pos2-pos1);
+   RPath = estrndup(pos1, pos2 - pos1);
}
} else {
if (headers) {
@@ -360,7 +360,7 @@
 
 
 /*
-// Name:  TSendText
+// Name:  SendText
 // Input:   1) RPath:   return path of the message
 //  Is used to fill the Return-Path and the
 //  X-Sender fields of the message.
@@ -411,17 +411,20 @@
/* attempt reconnect if the first Post fail */
if ((res = Post(Buffer)) != SUCCESS) {
MailConnect();
-   if ((res = Post(Buffer)) != SUCCESS)
+   if ((res = Post(Buffer)) != SUCCESS) {
return (res);
+   }
}
if ((res = Ack(server_response)) != SUCCESS) {
SMTP_ERROR_RESPONSE(server_response);
return (res);
}
 
+   SMTP_SKIP_SPACE(RPath);
snprintf(Buffer, MAIL_BUFFER_SIZE, MAIL FROM:%s\r\n, RPath);
-   if ((res = Post(Buffer)) != SUCCESS)
+   if ((res = Post(Buffer)) != SUCCESS) {
return (res);
+   }
if ((res = Ack(server_response)) != SUCCESS) {
SMTP_ERROR_RESPONSE(server_response);
return W32_SM_SENDMAIL_FROM_MALFORMED;
@@ -430,8 +433,9 @@
tempMailTo = estrdup(mailTo);
/* Send mail to all rcpt's */
token = strtok(tempMailTo, ,);
-   while(token != NULL)
+   while (token != NULL)
{
+   SMTP_SKIP_SPACE(token);
snprintf(Buffer, MAIL_BUFFER_SIZE, RCPT TO:%s\r\n, token);
if ((res = Post(Buffer)) != SUCCESS) {
efree(tempMailTo);
@@ -450,8 +454,9 @@
tempMailTo = estrdup(mailCc);
/* Send mail to all rcpt's */
token = strtok(tempMailTo, ,);
-   while(token != NULL)
+   while (token != NULL)
{
+   SMTP_SKIP_SPACE(token);
snprintf(Buffer, MAIL_BUFFER_SIZE, RCPT TO:%s\r\n, 
token);
if ((res = Post(Buffer)) != SUCCESS) {
efree(tempMailTo);
@@ -473,23 +478,23 @@
 * the cc: */
pos1 = headers + (pos1 - headers_lc) + 3;
if (NULL == (pos2 = strstr(pos1, \r\n))) {
-
tempMailTo = estrndup(pos1, strlen(pos1));
-
} else {
-   tempMailTo = estrndup(pos1, pos2-pos1);
-
+   tempMailTo = estrndup(pos1, pos2 - pos1);
}
 
token = strtok(tempMailTo, ,);
-   while(token != NULL)
+   while (token != NULL)
{
SMTP_SKIP_SPACE(token);
-   sprintf(Buffer, RCPT TO:%s\r\n, token);
-   if ((res = Post(Buffer)) != SUCCESS)
+   snprintf(Buffer, MAIL_BUFFER_SIZE, RCPT TO:%s\r\n, 
token);
+   if ((res = Post(Buffer)) != SUCCESS) {
+   efree(tempMailTo);
return (res);
+   }
if ((res = Ack(server_response)) != SUCCESS) {
SMTP_ERROR_RESPONSE(server_response);
+   efree(tempMailTo);
return (res);
}
token = strtok(NULL, ,);
@@ -504,7 +509,7 @@
tempMailTo = estrdup(mailBcc);
/* Send mail to all rcpt's */
token = strtok(tempMailTo, ,);
-   while(token != NULL)
+   while (token 

[PHP-CVS] cvs: php-src /win32 sendmail.c

2005-07-28 Thread Anantha Kesari H Y
hyanantha   Thu Jul 28 05:44:13 2005 EDT

  Modified files:  
/php-src/win32  sendmail.c 
  Log:
  NetWare cleanup
  --Kamesh
  
  
http://cvs.php.net/diff.php/php-src/win32/sendmail.c?r1=1.63r2=1.64ty=u
Index: php-src/win32/sendmail.c
diff -u php-src/win32/sendmail.c:1.63 php-src/win32/sendmail.c:1.64
--- php-src/win32/sendmail.c:1.63   Sat Mar 12 07:03:50 2005
+++ php-src/win32/sendmail.cThu Jul 28 05:44:13 2005
@@ -17,7 +17,7 @@
  *
  */
 
-/* $Id: sendmail.c,v 1.63 2005/03/12 12:03:50 andrey Exp $ */
+/* $Id: sendmail.c,v 1.64 2005/07/28 09:44:13 hyanantha Exp $ */
 
 #include php.h   /*php specific */
 #include stdio.h
@@ -83,13 +83,11 @@
 #ifndef NETWARE
 WSADATA Data;
 struct hostent *adr;
-#endif /* NETWARE */
-SOCKADDR_IN sock_in;
-#ifndef NETWARE
 int WinsockStarted;
 /* values set by the constructor */
 char *AppName;
 #endif /* NETWARE */
+SOCKADDR_IN sock_in;
 char MailHost[HOST_NAME_LEN];
 char LocalHost[HOST_NAME_LEN];
 #endif
@@ -348,14 +346,7 @@
*/
 
shutdown(sc, 0); 
-#ifndef NETWARE
closesocket(sc);
-#else
-   /* closesocket commented out since it was giving undefined symbol 
linker error
-* close added in its place
-*/
-   close(sc);
-#endif /* NETWARE */
 }
 
 
@@ -843,11 +834,7 @@
 // Author/Date:  jcar 20/9/96
 // History:
 ///
-#ifndef NETWARE
 int Post(LPCSTR msg)
-#else
-int Post(char *msg)
-#endif
 {
int len = strlen(msg);
int slen;
@@ -934,11 +921,7 @@
 // Author/Date:  jcar 20/9/96
 // History:
 ///
-#ifndef NETWARE
 unsigned long GetAddr(LPSTR szHost)
-#else
-unsigned long GetAddr(char * szHost)
-#endif
 {
LPHOSTENT lpstHost;
u_long lAddr = INADDR_ANY;
@@ -954,11 +937,7 @@
 
lpstHost = gethostbyname(szHost);
if (lpstHost) { /* success */
-#ifndef NETWARE
lAddr = *((u_long FAR *) (lpstHost-h_addr));
-#else
-   lAddr = *((u_long *) (lpstHost-h_addr));
-#endif /* NETWARE */
} else {
lAddr = INADDR_ANY; /* failure */
}

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /win32 sendmail.c

2005-02-25 Thread Anantha Kesari H Y
hyanantha   Fri Feb 25 00:57:43 2005 EDT

  Modified files:  
/php-src/win32  sendmail.c 
  Log:
  time.h is available in NetWare LibC.
  path sperator has been changed from \ to / while including 
netware\sendmail_nw.h 
  
  
http://cvs.php.net/diff.php/php-src/win32/sendmail.c?r1=1.61r2=1.62ty=u
Index: php-src/win32/sendmail.c
diff -u php-src/win32/sendmail.c:1.61 php-src/win32/sendmail.c:1.62
--- php-src/win32/sendmail.c:1.61   Wed Jan 19 13:54:23 2005
+++ php-src/win32/sendmail.cFri Feb 25 00:57:41 2005
@@ -17,17 +17,17 @@
  *
  */
 
-/* $Id: sendmail.c,v 1.61 2005/01/19 18:54:23 iliaa Exp $ */
+/* $Id: sendmail.c,v 1.62 2005/02/25 05:57:41 hyanantha Exp $ */
 
 #include php.h   /*php specific */
 #include stdio.h
 #include stdlib.h
 #ifndef NETWARE
 #include winsock2.h
+#include time.h
 #else  /* NETWARE */
-#include netware\sendmail_nw.h
+#include netware/sendmail_nw.h
 #endif /* NETWARE */
-#include time.h
 #include string.h
 #include math.h
 #ifndef NETWARE

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /win32 sendmail.c

2005-01-19 Thread Jani Taskinen
sniper  Wed Jan 19 12:38:21 2005 EDT

  Modified files:  
/php-src/win32  sendmail.c 
  Log:
  - Fixed bug #28976 (use From: from headers if sendmail_from is empty)
  
http://cvs.php.net/diff.php/php-src/win32/sendmail.c?r1=1.59r2=1.60ty=u
Index: php-src/win32/sendmail.c
diff -u php-src/win32/sendmail.c:1.59 php-src/win32/sendmail.c:1.60
--- php-src/win32/sendmail.c:1.59   Mon Dec  8 17:10:42 2003
+++ php-src/win32/sendmail.cWed Jan 19 12:38:20 2005
@@ -17,7 +17,7 @@
  *
  */
 
-/* $Id: sendmail.c,v 1.59 2003/12/08 22:10:42 fmk Exp $ */
+/* $Id: sendmail.c,v 1.60 2005/01/19 17:38:20 sniper Exp $ */
 
 #include php.h   /*php specific */
 #include stdio.h
@@ -225,6 +225,7 @@
int ret;
char *RPath = NULL;
char *headers_lc = NULL; /* headers_lc is only created if we've a 
header at all */
+   char *pos1 = NULL, *pos2 = NULL;
TSRMLS_FETCH();
 
 #ifndef NETWARE
@@ -266,9 +267,21 @@
/* Fall back to sendmail_from php.ini setting */
if (mailRPath  *mailRPath) {
RPath = estrdup(mailRPath);
-   }
-   else if (INI_STR(sendmail_from)) {
+   } else if (INI_STR(sendmail_from)) {
RPath = estrdup(INI_STR(sendmail_from));
+   } else if ( headers_lc 
+   (pos1 = strstr(headers_lc, from:)) 
+   ((pos1 == headers_lc) || (*(pos1-1) == '\n'))
+   ) {
+   /* Real offset is memaddress from the original headers + 
difference of
+* string found in the lowercase headrs + 5 characters to jump 
over   
+* the from: */
+   pos1 = headers + (pos1 - headers_lc) + 5;
+   if (NULL == (pos2 = strstr(pos1, \r\n))) {
+   RPath = estrndup(pos1, strlen(pos1));
+   } else {
+   RPath = estrndup(pos1, pos2-pos1);
+   }
} else {
if (headers) {
efree(headers);



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /win32 sendmail.c

2005-01-19 Thread Ilia Alshanetsky
iliaa   Wed Jan 19 13:54:23 2005 EDT

  Modified files:  
/php-src/win32  sendmail.c 
  Log:
  Stricter cc header check.
  
  
http://cvs.php.net/diff.php/php-src/win32/sendmail.c?r1=1.60r2=1.61ty=u
Index: php-src/win32/sendmail.c
diff -u php-src/win32/sendmail.c:1.60 php-src/win32/sendmail.c:1.61
--- php-src/win32/sendmail.c:1.60   Wed Jan 19 12:38:20 2005
+++ php-src/win32/sendmail.cWed Jan 19 13:54:23 2005
@@ -17,7 +17,7 @@
  *
  */
 
-/* $Id: sendmail.c,v 1.60 2005/01/19 17:38:20 sniper Exp $ */
+/* $Id: sendmail.c,v 1.61 2005/01/19 18:54:23 iliaa Exp $ */
 
 #include php.h   /*php specific */
 #include stdio.h
@@ -485,7 +485,7 @@
efree(tempMailTo);
}
/* Send mail to all Cc rcpt's */
-   else if (headers  (pos1 = strstr(headers_lc, cc:))  ((pos1 == 
headers_lc) || iscntrl(*(pos1-1 {
+   else if (headers  (pos1 = strstr(headers_lc, cc:))  ((pos1 == 
headers_lc) || (*(pos1-1) == '\n'))) {
/* Real offset is memaddress from the original headers + 
difference of
 * string found in the lowercase headrs + 3 characters to jump 
over
 * the cc: */

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /win32 sendmail.c sendmail.h

2003-12-08 Thread Frank M. Kromann
fmk Mon Dec  8 17:10:45 2003 EDT

  Modified files:  
/php-src/win32  sendmail.c sendmail.h 
  Log:
  Exporting symbols used in the imap extension
  
Index: php-src/win32/sendmail.c
diff -u php-src/win32/sendmail.c:1.58 php-src/win32/sendmail.c:1.59
--- php-src/win32/sendmail.c:1.58   Mon Sep  8 18:36:59 2003
+++ php-src/win32/sendmail.cMon Dec  8 17:10:42 2003
@@ -17,7 +17,7 @@
  *
  */
 
-/* $Id: sendmail.c,v 1.58 2003/09/08 22:36:59 iliaa Exp $ */
+/* $Id: sendmail.c,v 1.59 2003/12/08 22:10:42 fmk Exp $ */
 
 #include php.h   /*php specific */
 #include stdio.h
@@ -218,7 +218,7 @@
 //
 //  See SendText() for additional args!
 ///
-int TSendMail(char *host, int *error, char **error_message,
+PHPAPI int TSendMail(char *host, int *error, char **error_message,
  char *headers, char *Subject, char *mailTo, char *data,
  char *mailCc, char *mailBcc, char *mailRPath)
 {
@@ -323,7 +323,7 @@
 // Author/Date:  jcar 20/9/96
 // History:
 ///
-void TSMClose()
+PHPAPI void TSMClose()
 {
Post(QUIT\r\n);
Ack(NULL);
@@ -352,7 +352,7 @@
 // Author/Date:  jcar 20/9/96
 // History:
 //***/
-char *GetSMErrorText(int index)
+PHPAPI char *GetSMErrorText(int index)
 {
if (MIN_ERROR_INDEX = index  index  MAX_ERROR_INDEX) {
return (ErrorMessages[index]);
Index: php-src/win32/sendmail.h
diff -u php-src/win32/sendmail.h:1.12 php-src/win32/sendmail.h:1.13
--- php-src/win32/sendmail.h:1.12   Fri Jan  3 10:17:43 2003
+++ php-src/win32/sendmail.hMon Dec  8 17:10:42 2003
@@ -34,13 +34,13 @@
 #define MAX_ERROR_INDEX22 /* Always last 
error message + 1 */
 
 
-int TSendMail(char *smtpaddr, int *returnerror, char **error_message,
+PHPAPI int TSendMail(char *smtpaddr, int *returnerror, char **error_message,
  char *RPath, char *Subject, char *mailTo, char *data,
  char *mailCc, char *mailBcc, char *mailRPath);
-void TSMClose(void);
+PHPAPI void TSMClose(void);
 int SendText(char *RPath, char *Subject, char *mailTo, char *mailCc, char *mailBcc, 
char *data, 
 char *headers, char *headers_lc, char **error_message);
-char *GetSMErrorText(int index);
+PHPAPI char *GetSMErrorText(int index);
 
 int MailConnect();
 int PostHeader(char *, char *, char *, char *);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /win32 sendmail.c

2003-08-11 Thread Ilia Alshanetsky
iliaa   Mon Aug 11 14:03:24 2003 EDT

  Modified files:  
/php-src/win32  sendmail.c 
  Log:
  Fixed bug #22947 (Ack() inside win32/sendmail.c may stall in certain 
  situations).
  
  
Index: php-src/win32/sendmail.c
diff -u php-src/win32/sendmail.c:1.56 php-src/win32/sendmail.c:1.57
--- php-src/win32/sendmail.c:1.56   Mon Aug 11 12:37:32 2003
+++ php-src/win32/sendmail.cMon Aug 11 14:03:24 2003
@@ -17,7 +17,7 @@
  *
  */
 
-/* $Id: sendmail.c,v 1.56 2003/08/11 16:37:32 iliaa Exp $ */
+/* $Id: sendmail.c,v 1.57 2003/08/11 18:03:24 iliaa Exp $ */
 
 #include php.h   /*php specific */
 #include stdio.h
@@ -883,11 +883,11 @@
/* Check for newline */
Index += rlen;

-   if ((buf[Received - 4] == ' '  buf[Received - 3] == '-') ||
-   (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
-  And not contain a space followed by a '-' */
+   /* SMPT RFC says \r\n is the only valid line ending, who are we to argue ;)
+* The response code must contain at least 5 characters ex. 220\r\n */
+   if (Received  5 || buf[Received - 1] != '\n' || buf[Received - 2] != '\r') {
+   goto again;
+   }
 
if (buf[0]  '3') {
/* If we've a valid pointer, return the SMTP server response so the 
error message contains more information */



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /win32 sendmail.c

2003-07-23 Thread Ilia Alshanetsky
iliaa   Wed Jul 23 12:03:10 2003 EDT

  Modified files:  
/php-src/win32  sendmail.c 
  Log:
  Fixed bug #23798 (Spaces were not being stripped from Bcc header)
  Fixed bug #24663 (\n. sequences were not being escaped)
  
  
  
  
Index: php-src/win32/sendmail.c
diff -u php-src/win32/sendmail.c:1.54 php-src/win32/sendmail.c:1.55
--- php-src/win32/sendmail.c:1.54   Sat Feb 15 22:48:49 2003
+++ php-src/win32/sendmail.cWed Jul 23 12:03:10 2003
@@ -17,7 +17,7 @@
  *
  */
 
-/* $Id: sendmail.c,v 1.54 2003/02/16 03:48:49 wez Exp $ */
+/* $Id: sendmail.c,v 1.55 2003/07/23 16:03:10 iliaa Exp $ */
 
 #include php.h   /*php specific */
 #include stdio.h
@@ -29,6 +29,7 @@
 #endif /* NETWARE */
 #include time.h
 #include string.h
+#include math.h
 #ifndef NETWARE
 #include malloc.h
 #include memory.h
@@ -41,6 +42,8 @@
 #include ext/pcre/php_pcre.h
 #endif
 
+#include ext/standard/php_string.h
+
 /*
extern int _daylight;
extern long _timezone;
@@ -69,6 +72,8 @@
   
 efree(response); \
   
 } \
}
+#define SMTP_SKIP_SPACE(str)   { while (isspace(*str)) { str++; } }
+
 
 #ifndef THREAD_SAFE
 char Buffer[MAIL_BUFFER_SIZE];
@@ -139,6 +144,13 @@
 #define PHP_WIN32_MAIL_RMVDBL_PATTERN  /^\r\n|(\r\n)+$/m
 #define PHP_WIN32_MAIL_RMVDBL_REPLACE  
 
+/* This pattern escapes \n. inside the message body. It prevents
+ * premature end of message if \n.\n or \r\n.\r\n is encountered
+ * and ensures that \n. sequences are properly displayed in the
+ * message body. */
+#define PHP_WIN32_MAIL_DOT_PATTERN \n.
+#define PHP_WIN32_MAIL_DOT_REPLACE \n..
+
 /* This function is meant to unify the headers passed to to mail()
  * This means, use PCRE to transform single occurences of \n or \r in \r\n
  * As a second step we also eleminate all \r\n occurences which are:
@@ -378,6 +390,8 @@
char *tempMailTo, *token, *pos1, *pos2;
char *server_response = NULL;
char *stripped_header  = NULL;
+   char *data_cln;
+   int data_cln_len;
 
/* check for NULL parameters */
if (data == NULL)
@@ -475,6 +489,7 @@
token = strtok(tempMailTo, ,);
while(token != NULL)
{
+   SMTP_SKIP_SPACE(token);
sprintf(Buffer, RCPT TO:%s\r\n, token);
if ((res = Post(Buffer)) != SUCCESS)
return (res);
@@ -496,6 +511,7 @@
token = strtok(tempMailTo, ,);
while(token != NULL)
{
+   SMTP_SKIP_SPACE(token);
snprintf(Buffer, MAIL_BUFFER_SIZE, RCPT TO:%s\r\n, token);
if ((res = Post(Buffer)) != SUCCESS) {
efree(tempMailTo);
@@ -529,6 +545,7 @@
token = strtok(tempMailTo, ,);
while(token != NULL)
{
+   SMTP_SKIP_SPACE(token);
sprintf(Buffer, RCPT TO:%s\r\n, token);
if ((res = Post(Buffer)) != SUCCESS) {
return (res);
@@ -597,30 +614,43 @@
return (res);
}
 
+   /* Escape \n. sequences
+* We use php_str_to_str() and not php_str_replace_in_subject(), since the 
latter
+* uses ZVAL as it's parameters */
+   data_cln = php_str_to_str(data, strlen(data), PHP_WIN32_MAIL_DOT_PATTERN, 
sizeof(PHP_WIN32_MAIL_DOT_PATTERN) - 1,
+   PHP_WIN32_MAIL_DOT_REPLACE, 
sizeof(PHP_WIN32_MAIL_DOT_REPLACE) - 1, data_cln_len);
+
/* send message contents in 1024 chunks */
-   if (strlen(data) = 1024) {
-   if ((res = Post(data)) != SUCCESS)
+   if (data_cln_len = 1024) {
+   if ((res = Post(data_cln)) != SUCCESS) {
+   efree(data_cln);
return (res);
+   }
} else {
-   p = data;
-   while (1) {
-   if (*p == '\0')
-   break;
-   if (strlen(p) = 1024)
-   i = 1024;
-   else
-   i = strlen(p);
-
-   /* put next chunk in buffer */
-   strncpy(Buffer, p, i);
-   Buffer[i] = '\0';
-   p += i;
+   int parts = (int) floor(data_cln_len / 1024);
+   p = data_cln;
 
+   for (i = 0; i  parts; i++) {
+   strlcpy(Buffer, p, 1024);
+   Buffer[1024] = '\0';