Forum Replies Created

Viewing 1 replies (of 1 total)
  • WT,

    I got the code above by stonicus to work, basically you are only editing the top part of a long section of code, the wp_mail function. The last return line is a ways down and so you are pasting the original code into the modified code that stonicus provided EXCEPT that last return $result line. You need to add a } and then add return $result on the next line.

    The wp_mail function of the pluggaple.php code should look like this:

    function wp_mail( $targets, $subject, $message, $headers = '' )
    {
    	$tars = explode(",", $targets);
    	foreach($tars as $to)
    	{
    // Compact the input, apply the filters, and extract them back out
    	extract( apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers' ) ) );
    
    	global $phpmailer;
    
    	// (Re)create it, if it's gone missing
    	if ( !is_object( $phpmailer ) || !is_a( $phpmailer, 'PHPMailer' ) ) {
    		require_once ABSPATH . WPINC . '/class-phpmailer.php';
    		require_once ABSPATH . WPINC . '/class-smtp.php';
    		$phpmailer = new PHPMailer();
    	}
    
    	// Headers
    	if ( empty( $headers ) ) {
    		$headers = array();
    	} elseif ( !is_array( $headers ) ) {
    		// Explode the headers out, so this function can take both
    		// string headers and an array of headers.
    		$tempheaders = (array) explode( "\n", $headers );
    		$headers = array();
    
    		// If it's actually got contents
    		if ( !empty( $tempheaders ) ) {
    			// Iterate through the raw headers
    			foreach ( $tempheaders as $header ) {
    				if ( strpos($header, ':') === false )
    					continue;
    				// Explode them out
    				list( $name, $content ) = explode( ':', trim( $header ), 2 );
    
    				// Cleanup crew
    				$name = trim( $name );
    				$content = trim( $content );
    
    				// Mainly for legacy -- process a From: header if it's there
    				if ( 'from' == strtolower($name) ) {
    					if ( strpos($content, '<' ) !== false ) {
    						// So... making my life hard again?
    						$from_name = substr( $content, 0, strpos( $content, '<' ) - 1 );
    						$from_name = str_replace( '"', '', $from_name );
    						$from_name = trim( $from_name );
    
    						$from_email = substr( $content, strpos( $content, '<' ) + 1 );
    						$from_email = str_replace( '>', '', $from_email );
    						$from_email = trim( $from_email );
    					} else {
    						$from_name = trim( $content );
    					}
    				} elseif ( 'content-type' == strtolower($name) ) {
    					if ( strpos( $content,';' ) !== false ) {
    						list( $type, $charset ) = explode( ';', $content );
    						$content_type = trim( $type );
    						$charset = trim( str_replace( array( 'charset=', '"' ), '', $charset ) );
    					} else {
    						$content_type = trim( $content );
    					}
    				} elseif ( 'cc' == strtolower($name) ) {
    					$cc = explode(",", $content);
    				} elseif ( 'bcc' == strtolower($name) ) {
    					$bcc = explode(",", $content);
    				} else {
    					// Add it to our grand headers array
    					$headers[trim( $name )] = trim( $content );
    				}
    			}
    		}
    	}
    
    	// Empty out the values that may be set
    	$phpmailer->ClearAddresses();
    	$phpmailer->ClearAllRecipients();
    	$phpmailer->ClearAttachments();
    	$phpmailer->ClearBCCs();
    	$phpmailer->ClearCCs();
    	$phpmailer->ClearCustomHeaders();
    	$phpmailer->ClearReplyTos();
    
    	// From email and name
    	// If we don't have a name from the input headers
    	if ( !isset( $from_name ) ) {
    		$from_name = 'WordPress';
    	}
    
    	// If we don't have an email from the input headers
    	if ( !isset( $from_email ) ) {
    		// Get the site domain and get rid of www.
    		$sitename = strtolower( $_SERVER['SERVER_NAME'] );
    		if ( substr( $sitename, 0, 4 ) == 'www.' ) {
    			$sitename = substr( $sitename, 4 );
    		}
    
    		$from_email = 'wordpress@' . $sitename;
    	}
    
    	// Set the from name and email
    	$phpmailer->From = apply_filters( 'wp_mail_from', $from_email );
    	$phpmailer->FromName = apply_filters( 'wp_mail_from_name', $from_name );
    
    	// Set destination address
    	$phpmailer->AddAddress( $to );
    
    	// Set mail's subject and body
    	$phpmailer->Subject = $subject;
    	$phpmailer->Body = $message;
    
    	// Add any CC and BCC recipients
    	if ( !empty($cc) ) {
    		foreach ($cc as $recipient) {
    			$phpmailer->AddCc( trim($recipient) );
    		}
    	}
    	if ( !empty($bcc) ) {
    		foreach ($bcc as $recipient) {
    			$phpmailer->AddBcc( trim($recipient) );
    		}
    	}
    
    	// Set to use PHP's mail()
    	$phpmailer->IsMail();
    
    	// Set Content-Type and charset
    	// If we don't have a content-type from the input headers
    	if ( !isset( $content_type ) ) {
    		$content_type = 'text/plain';
    	}
    
    	$content_type = apply_filters( 'wp_mail_content_type', $content_type );
    
    	// Set whether it's plaintext or not, depending on $content_type
    	if ( $content_type == 'text/html' ) {
    		$phpmailer->IsHTML( true );
    	} else {
    		$phpmailer->IsHTML( false );
    	}
    
    	// If we don't have a charset from the input headers
    	if ( !isset( $charset ) ) {
    		$charset = get_bloginfo( 'charset' );
    	}
    
    	// Set the content-type and charset
    	$phpmailer->CharSet = apply_filters( 'wp_mail_charset', $charset );
    
    	// Set custom headers
    	if ( !empty( $headers ) ) {
    		foreach ( $headers as $name => $content ) {
    			$phpmailer->AddCustomHeader( sprintf( '%1$s: %2$s', $name, $content ) );
    		}
    	}
    
    	do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) );
    
    	// Send!
    	$result = @$phpmailer->Send();
    
    	}
    	return $result;
    }
    endif;
Viewing 1 replies (of 1 total)