diff options
| author | the_systech <the_systech@users.sourceforge.net> | 2002-01-04 17:25:54 +0000 | 
|---|---|---|
| committer | the_systech <the_systech@users.sourceforge.net> | 2002-01-04 17:25:54 +0000 | 
| commit | 58ad760b3c4b6604fa96d794f90a5d0211f43a80 (patch) | |
| tree | 4d6961e2e84332ee9007d7a31e6c1d7682bf5811 | |
| parent | 8f973330a55e152b11da914bc0aa905ee2be2c0a (diff) | |
| download | forums-58ad760b3c4b6604fa96d794f90a5d0211f43a80.tar forums-58ad760b3c4b6604fa96d794f90a5d0211f43a80.tar.gz forums-58ad760b3c4b6604fa96d794f90a5d0211f43a80.tar.bz2 forums-58ad760b3c4b6604fa96d794f90a5d0211f43a80.tar.xz forums-58ad760b3c4b6604fa96d794f90a5d0211f43a80.zip | |
fix for mass mail bug, plus some cleanups for php3 compatibility..CC and BCC headers are now handled properly, and there is no longer any foreach statments used.
git-svn-id: file:///svn/phpbb/trunk@1799 89ea8834-ac86-4346-8a33-228a782c2dd0
| -rw-r--r-- | phpBB/includes/smtp.php | 49 | 
1 files changed, 44 insertions, 5 deletions
| diff --git a/phpBB/includes/smtp.php b/phpBB/includes/smtp.php index 13c90e7e80..f14e836730 100644 --- a/phpBB/includes/smtp.php +++ b/phpBB/includes/smtp.php @@ -80,8 +80,34 @@ function smtpmail($mail_to, $subject, $message, $headers = "")  		}  		$headers = chop($headers); +		//  		// Make sure there are no bare linefeeds in the headers +		//  		$headers = preg_replace("/(?<!\r)\n/si", "\r\n", $headers); +		// +		// Ok this is rather confusing all things considered, +		// but we have to grab bcc and cc headers and treat them differently +		// Something we really didn't take into consideration originally +		// +		$header_array = explode("\r\n", $headers); +		@reset($header_array); +		$headers = ""; +		while( list(, $header) = each($header_array) ) +		{ +			if( preg_match("/^cc:/si", $header) ) +			{ +				$cc = preg_replace("/^cc:(.*)/si", "\\1", $header); +			} +			else if( preg_match("/^bcc:/si", $header )) +			{ +				$bcc = preg_replace("/^bcc:(.*)/si", "\\1", $header); +				$header = ""; +			} +			$headers .= $header . "\r\n"; +		} +		$headers = chop($headers); +		$cc = explode(",", $cc); +		$bcc = explode(",", $bcc);  	}  	if(trim($mail_to) == "")  	{ @@ -119,13 +145,26 @@ function smtpmail($mail_to, $subject, $message, $headers = "")  	// Specify each user to send to and build to header.  	$to_header = "To: "; -	foreach($mail_to_array as $mail_to_address) +	@reset( $mail_to_array ); +	while( list( , $mail_to_address ) = each( $mail_to_array ))  	{ -		fputs($socket, "RCPT TO: $mail_to_address\r\n"); -		server_parse($socket, "250"); +		fputs( $socket, "RCPT TO: $mail_to_address\r\n" ); +		server_parse( $socket, "250" );  		$to_header .= "<$mail_to_address>, ";  	} - +	// Ok now do the CC and BCC fields... +	@reset( $bcc ); +	while( list( , $bcc_address ) = each( $bcc )) +	{ +		fputs( $socket, "RCPT TO: $bcc_address\r\n" ); +		server_parse( $socket, "250" ); +	} +	@reset( $cc ); +	while( list( , $cc_address ) = each( $cc )) +	{ +		fputs($socket, "RCPT TO: $cc_address\r\n"); +		server_parse($socket, "250"); +	}  	// Ok now we tell the server we are ready to start sending data  	fputs($socket, "DATA\r\n"); @@ -155,4 +194,4 @@ function smtpmail($mail_to, $subject, $message, $headers = "")  	return TRUE;  } -?>
\ No newline at end of file +?> | 
