mirror of
https://github.com/php/php-src.git
synced 2024-11-23 18:04:36 +08:00
- Fix win32 sendmail bug with Cc: in custom header not terminated with \r\n
- Fix some obvious errors returned by the module, little cleanup.
This commit is contained in:
parent
ce2b2b76a0
commit
87286cdb3f
@ -69,26 +69,27 @@ char *get_header(char *h, char *headers);
|
||||
/* Error messages */
|
||||
static char *ErrorMessages[] =
|
||||
{
|
||||
{"Success"},
|
||||
{"Bad arguments from form"},
|
||||
{"Success"}, /* 0 */
|
||||
{"Bad arguments from form"}, /* 1 */
|
||||
{"Unable to open temporary mailfile for read"},
|
||||
{"Failed to Start Sockets"},
|
||||
{"Failed to Resolve Host"},
|
||||
{"Failed to obtain socket handle"},
|
||||
{"Failed to Connect"},
|
||||
{"Failed to obtain socket handle"}, /* 5 */
|
||||
{"Failed to connect to mailserver, verify your \"SMTP\" setting in php.ini"},
|
||||
{"Failed to Send"},
|
||||
{"Failed to Receive"},
|
||||
{"Server Error"},
|
||||
{"Failed to resolve the host IP name"},
|
||||
{"Failed to resolve the host IP name"}, /* 10 */
|
||||
{"Out of memory"},
|
||||
{"Unknown error"},
|
||||
{"Bad Message Contents"},
|
||||
{"Bad Message Subject"},
|
||||
{"Bad Message destination"},
|
||||
{"Bad Message destination"}, /* 15 */
|
||||
{"Bad Message Return Path"},
|
||||
{"Bad Mail Host"},
|
||||
{"Bad Message File"},
|
||||
{"PHP Internal error: php.ini sendmail from variable not set!"}
|
||||
{"\"sendmail_from\" NOT set in php.ini"},
|
||||
{"Mailserver rejected our \"sendmail_from\" setting"} /* 20 */
|
||||
};
|
||||
|
||||
|
||||
@ -127,7 +128,8 @@ int TSendMail(char *host, int *error,
|
||||
if (INI_STR("sendmail_from")){
|
||||
RPath = estrdup(INI_STR("sendmail_from"));
|
||||
} else {
|
||||
return 19;
|
||||
*error = W32_SM_SENDMAIL_FROM_NOT_SET;
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
/* attempt to connect with mail host */
|
||||
@ -179,10 +181,11 @@ void TSMClose()
|
||||
char *GetSMErrorText(int index)
|
||||
{
|
||||
|
||||
if ((index > MAX_ERROR_INDEX) || (index < MIN_ERROR_INDEX))
|
||||
return (ErrorMessages[UNKNOWN_ERROR]);
|
||||
else
|
||||
if (MIN_ERROR_INDEX <= index && index < MAX_ERROR_INDEX) {
|
||||
return (ErrorMessages[index]);
|
||||
} else {
|
||||
return (ErrorMessages[UNKNOWN_ERROR]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -235,7 +238,7 @@ int SendText(char *RPath, char *Subject, char *mailTo, char *data, char *headers
|
||||
if ((res = Post(Buffer)) != SUCCESS)
|
||||
return (res);
|
||||
if ((res = Ack()) != SUCCESS)
|
||||
return (res);
|
||||
return W32_SM_SENDMAIL_FROM_MALFORMED;
|
||||
|
||||
|
||||
tempMailTo = estrdup(mailTo);
|
||||
@ -255,8 +258,11 @@ int SendText(char *RPath, char *Subject, char *mailTo, char *data, char *headers
|
||||
/* 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);
|
||||
if (NULL == (pos2 = strstr(pos1, "\r\n"))) {
|
||||
tempMailTo = estrndup(pos1, strlen(pos1));
|
||||
} else {
|
||||
tempMailTo = estrndup(pos1, pos2-pos1);
|
||||
}
|
||||
|
||||
token = strtok(tempMailTo, ",");
|
||||
while(token != NULL)
|
||||
|
@ -4,29 +4,31 @@
|
||||
|
||||
#define HOST_NAME_LEN 256
|
||||
#define MAX_APPNAME_LENGHT 100
|
||||
#define MAX_ERROR_INDEX 17
|
||||
#define MIN_ERROR_INDEX 0
|
||||
#define MAIL_BUFFER_SIZE (1024*4) /* 4k buffer */
|
||||
#define MAIL_BUFFER_SIZE (1024*4) /* 4k buffer */
|
||||
/* Return values */
|
||||
#define SUCCESS 0
|
||||
#define FAILED_TO_PARSE_ARGUMENTS 1
|
||||
#define FAILED_TO_OPEN_MAILFILE 2
|
||||
#define FAILED_TO_START_SOCKETS 3
|
||||
#define FAILED_TO_RESOLVE_HOST 4
|
||||
#define FAILED_TO_OBTAIN_SOCKET_HANDLE 5
|
||||
#define FAILED_TO_CONNECT 6
|
||||
#define FAILED_TO_SEND 7
|
||||
#define FAILED_TO_RECEIVE 8
|
||||
#define SMTP_SERVER_ERROR 9
|
||||
#define FAILED_TO_GET_HOSTNAME 10
|
||||
#define OUT_OF_MEMORY 11
|
||||
#define UNKNOWN_ERROR 12
|
||||
#define BAD_MSG_CONTENTS 13
|
||||
#define BAD_MSG_SUBJECT 14
|
||||
#define BAD_MSG_DESTINATION 15
|
||||
#define BAD_MSG_RPATH 16
|
||||
#define BAD_MAIL_HOST 17
|
||||
#define BAD_MSG_FILE 18
|
||||
#define MIN_ERROR_INDEX 0 /* Always 0 like SUCCESS */
|
||||
#define SUCCESS 0
|
||||
#define FAILED_TO_PARSE_ARGUMENTS 1
|
||||
#define FAILED_TO_OPEN_MAILFILE 2
|
||||
#define FAILED_TO_START_SOCKETS 3
|
||||
#define FAILED_TO_RESOLVE_HOST 4
|
||||
#define FAILED_TO_OBTAIN_SOCKET_HANDLE 5
|
||||
#define FAILED_TO_CONNECT 6
|
||||
#define FAILED_TO_SEND 7
|
||||
#define FAILED_TO_RECEIVE 8
|
||||
#define SMTP_SERVER_ERROR 9
|
||||
#define FAILED_TO_GET_HOSTNAME 10
|
||||
#define OUT_OF_MEMORY 11
|
||||
#define UNKNOWN_ERROR 12
|
||||
#define BAD_MSG_CONTENTS 13
|
||||
#define BAD_MSG_SUBJECT 14
|
||||
#define BAD_MSG_DESTINATION 15
|
||||
#define BAD_MSG_RPATH 16
|
||||
#define BAD_MAIL_HOST 17
|
||||
#define BAD_MSG_FILE 18
|
||||
#define W32_SM_SENDMAIL_FROM_NOT_SET 19
|
||||
#define W32_SM_SENDMAIL_FROM_MALFORMED 20
|
||||
#define MAX_ERROR_INDEX 21 /* Always last error message + 1 */
|
||||
|
||||
|
||||
int TSendMail(char *smtpaddr, int *returnerror,
|
||||
|
Loading…
Reference in New Issue
Block a user