summaryrefslogtreecommitdiff
path: root/win32/sendmail.c
diff options
context:
space:
mode:
authorfoobar <sniper@php.net>2005-01-19 17:38:20 +0000
committerfoobar <sniper@php.net>2005-01-19 17:38:20 +0000
commit9feb47d70e5e5a6d95c2322aca5b3077b95039ff (patch)
treeb71f7996d02acbfff07e93d4d4f54fd13b45d156 /win32/sendmail.c
parent6faa433d580a1b0f3750f833dea820b584941b77 (diff)
downloadphp-git-9feb47d70e5e5a6d95c2322aca5b3077b95039ff.tar.gz
- Fixed bug #28976 (use From: from headers if sendmail_from is empty)
Diffstat (limited to 'win32/sendmail.c')
-rw-r--r--win32/sendmail.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/win32/sendmail.c b/win32/sendmail.c
index 98659d4db4..07e1275cb2 100644
--- a/win32/sendmail.c
+++ b/win32/sendmail.c
@@ -225,6 +225,7 @@ PHPAPI int TSendMail(char *host, int *error, char **error_message,
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 @@ PHPAPI int TSendMail(char *host, int *error, char **error_message,
/* 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);