summaryrefslogtreecommitdiff
path: root/win32/sendmail.c
diff options
context:
space:
mode:
authorMark A. Hershberger <mah@debian.(none)>2009-03-25 00:34:59 -0400
committerMark A. Hershberger <mah@debian.(none)>2009-03-25 00:34:59 -0400
commitce7edc9b3c7370f32fec0bc7a8ec3e29ed9a5f61 (patch)
treeacdb9a8816483652a9db1a47db71df5df43707c5 /win32/sendmail.c
parent10f5b47dc7c1cf2b9a00991629f43652710322d3 (diff)
downloadphp-ce7edc9b3c7370f32fec0bc7a8ec3e29ed9a5f61.tar.gz
Imported Upstream version 5.1.1upstream/5.1.1
Diffstat (limited to 'win32/sendmail.c')
-rw-r--r--win32/sendmail.c78
1 files changed, 27 insertions, 51 deletions
diff --git a/win32/sendmail.c b/win32/sendmail.c
index 57677556b..a466a599a 100644
--- a/win32/sendmail.c
+++ b/win32/sendmail.c
@@ -17,7 +17,7 @@
*
*/
-/* $Id: sendmail.c,v 1.59.2.4 2005/07/28 08:57:37 hyanantha Exp $ */
+/* $Id: sendmail.c,v 1.65 2005/08/07 22:06:29 sniper Exp $ */
#include "php.h" /*php specific */
#include <stdio.h>
@@ -42,23 +42,15 @@
#include "ext/pcre/php_pcre.h"
#endif
-#include "ext/standard/php_string.h"
+#include "ext/standard/php_string.h"
+#include "ext/date/php_date.h"
-/*
- extern int _daylight;
- extern long _timezone;
- */
/*enum
{
DO_CONNECT = WM_USER +1
};
*/
-static char *days[] =
-{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
-static char *months[] =
-{"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
-
/* '*error_message' has to be passed around from php_mail() */
#define SMTP_ERROR_RESPONSE_SPEC "SMTP server response: %s"
/* Convinient way to handle error messages from the SMTP server.
@@ -98,8 +90,6 @@ char *php_mailer = "PHP 4 WIN32";
char *php_mailer = "PHP 4 NetWare";
#endif /* NETWARE */
-char *get_header(char *h, char *headers);
-
/* Error messages */
static char *ErrorMessages[] =
{
@@ -180,7 +170,8 @@ static char *php_win32_mail_trim_header(char *header TSRMLS_DC)
replace,
0,
&result_len,
- -1 TSRMLS_CC);
+ -1,
+ NULL TSRMLS_CC);
if (NULL == result) {
FREE_ZVAL(replace);
return NULL;
@@ -193,7 +184,8 @@ static char *php_win32_mail_trim_header(char *header TSRMLS_DC)
replace,
0,
&result_len,
- -1 TSRMLS_CC);
+ -1,
+ NULL TSRMLS_CC);
efree(result);
FREE_ZVAL(replace);
return result2;
@@ -218,13 +210,12 @@ static char *php_win32_mail_trim_header(char *header TSRMLS_DC)
//********************************************************************/
PHPAPI int TSendMail(char *host, int *error, char **error_message,
char *headers, char *Subject, char *mailTo, char *data,
- char *mailCc, char *mailBcc, char *mailRPath)
+ char *mailCc, char *mailBcc, char *mailRPath TSRMLS_DC)
{
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
WinsockStarted = FALSE;
@@ -309,7 +300,7 @@ PHPAPI int TSendMail(char *host, int *error, char **error_message,
MailHost, !INI_INT("smtp_port") ? 25 : INI_INT("smtp_port"));
return FAILURE;
} else {
- ret = SendText(RPath, Subject, mailTo, mailCc, mailBcc, data, headers, headers_lc, error_message);
+ ret = SendText(RPath, Subject, mailTo, mailCc, mailBcc, data, headers, headers_lc, error_message TSRMLS_CC);
TSMClose();
if (RPath) {
efree(RPath);
@@ -386,8 +377,8 @@ PHPAPI char *GetSMErrorText(int index)
// Author/Date: jcar 20/9/96
// History:
//*******************************************************************/
-int SendText(char *RPath, char *Subject, char *mailTo, char *mailCc, char *mailBcc, char *data,
- char *headers, char *headers_lc, char **error_message)
+static int SendText(char *RPath, char *Subject, char *mailTo, char *mailCc, char *mailBcc, char *data,
+ char *headers, char *headers_lc, char **error_message TSRMLS_DC)
{
int res;
char *p;
@@ -607,9 +598,9 @@ int SendText(char *RPath, char *Subject, char *mailTo, char *mailCc, char *mailB
/* send message header */
if (Subject == NULL) {
- res = PostHeader(RPath, "No Subject", mailTo, stripped_header);
+ res = PostHeader(RPath, "No Subject", mailTo, stripped_header TSRMLS_CC);
} else {
- res = PostHeader(RPath, Subject, mailTo, stripped_header);
+ res = PostHeader(RPath, Subject, mailTo, stripped_header TSRMLS_CC);
}
if (stripped_header) {
efree(stripped_header);
@@ -663,7 +654,8 @@ int SendText(char *RPath, char *Subject, char *mailTo, char *mailCc, char *mailB
return (SUCCESS);
}
-int addToHeader(char **header_buffer, const char *specifier, char *string) {
+static int addToHeader(char **header_buffer, const char *specifier, char *string)
+{
if (NULL == (*header_buffer = erealloc(*header_buffer, strlen(*header_buffer) + strlen(specifier) + strlen(string) + 1))) {
return 0;
}
@@ -682,16 +674,12 @@ int addToHeader(char **header_buffer, const char *specifier, char *string) {
// Author/Date: jcar 20/9/96
// History:
//********************************************************************/
-int PostHeader(char *RPath, char *Subject, char *mailTo, char *xheaders)
+static int PostHeader(char *RPath, char *Subject, char *mailTo, char *xheaders TSRMLS_DC)
{
-
/* Print message header according to RFC 822 */
/* Return-path, Received, Date, From, Subject, Sender, To, cc */
- time_t tNow = time(NULL);
- struct tm *tm = localtime(&tNow);
- int zoneh = abs(_timezone);
- int zonem, res;
+ int res;
char *header_buffer;
char *headers_lc = NULL;
size_t i;
@@ -709,21 +697,13 @@ int PostHeader(char *RPath, char *Subject, char *mailTo, char *xheaders)
efree(headers_lc);
return OUT_OF_MEMORY;
}
- zoneh /= (60 * 60);
- zonem = (abs(_timezone) / 60) - (zoneh * 60);
- if(!xheaders || !strstr(headers_lc, "date:")){
- sprintf(header_buffer, "Date: %s, %02d %s %04d %02d:%02d:%02d %s%02d%02d\r\n",
- days[tm->tm_wday],
- tm->tm_mday,
- months[tm->tm_mon],
- tm->tm_year + 1900,
- tm->tm_hour,
- tm->tm_min,
- tm->tm_sec,
- (_timezone <= 0) ? "+" : (_timezone > 0) ? "-" : "",
- zoneh,
- zonem);
+ if (!xheaders || !strstr(headers_lc, "date:")) {
+ time_t tNow = time(NULL);
+ char *dt = php_format_date("r", 1, tNow, 1 TSRMLS_CC);
+
+ sprintf(header_buffer, "Date: %s\r\n", dt);
+ efree(dt);
}
if (!headers_lc || !strstr(headers_lc, "from:")) {
@@ -779,7 +759,7 @@ PostHeader_outofmem:
// Author/Date: jcar 20/9/96
// History:
//********************************************************************/
-int MailConnect()
+static int MailConnect()
{
int res;
@@ -820,10 +800,6 @@ int MailConnect()
}
-
-
-
-
/*********************************************************************
// Name: Post
// Input:
@@ -832,7 +808,7 @@ int MailConnect()
// Author/Date: jcar 20/9/96
// History:
//********************************************************************/
-int Post(LPCSTR msg)
+static int Post(LPCSTR msg)
{
int len = strlen(msg);
int slen;
@@ -859,7 +835,7 @@ int Post(LPCSTR msg)
// Author/Date: jcar 20/9/96
// History:
//********************************************************************/
-int Ack(char **server_response)
+static int Ack(char **server_response)
{
static char buf[MAIL_BUFFER_SIZE];
int rlen;
@@ -919,7 +895,7 @@ int Ack(char **server_response)
// Author/Date: jcar 20/9/96
// History:
//********************************************************************/
-unsigned long GetAddr(LPSTR szHost)
+static unsigned long GetAddr(LPSTR szHost)
{
LPHOSTENT lpstHost;
u_long lAddr = INADDR_ANY;