Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/pluggable.php

    r17386 r18195  
    282282        require_once ABSPATH . WPINC . '/class-phpmailer.php';
    283283        require_once ABSPATH . WPINC . '/class-smtp.php';
    284         $phpmailer = new PHPMailer();
     284        $phpmailer = new PHPMailer( true );
    285285    }
    286286
     
    297297        }
    298298        $headers = array();
     299        $cc = array();
     300        $bcc = array();
    299301
    300302        // If it's actually got contents
     
    401403
    402404    foreach ( (array) $to as $recipient ) {
    403         $phpmailer->AddAddress( trim( $recipient ) );
     405        try {
     406            // Break $recipient into name and address parts if in the format "Foo <bar@baz.com>"
     407            $recipient_name = '';
     408            if( preg_match( '/(.+)\s?<(.+)>/', $recipient, $matches ) ) {
     409                if ( count( $matches ) == 3 ) {
     410                    $recipient_name = $matches[1];
     411                    $recipient = $matches[2];
     412                }
     413            }
     414            $phpmailer->AddAddress( trim( $recipient ), $recipient_name);
     415        } catch ( phpmailerException $e ) {
     416            continue;
     417        }
    404418    }
    405419
     
    411425    if ( !empty( $cc ) ) {
    412426        foreach ( (array) $cc as $recipient ) {
    413             $phpmailer->AddCc( trim($recipient) );
     427            try {
     428                // Break $recipient into name and address parts if in the format "Foo <bar@baz.com>"
     429                $recipient_name = '';
     430                if( preg_match( '/(.+)\s?<(.+)>/', $recipient, $matches ) ) {
     431                    if ( count( $matches ) == 3 ) {
     432                        $recipient_name = $matches[1];
     433                        $recipient = $matches[2];
     434                    }
     435                }
     436                $phpmailer->AddCc( trim($recipient), $recipient_name );
     437            } catch ( phpmailerException $e ) {
     438                continue;
     439            }
    414440        }
    415441    }
     
    417443    if ( !empty( $bcc ) ) {
    418444        foreach ( (array) $bcc as $recipient) {
    419             $phpmailer->AddBcc( trim($recipient) );
     445            try {
     446                // Break $recipient into name and address parts if in the format "Foo <bar@baz.com>"
     447                $recipient_name = '';
     448                if( preg_match( '/(.+)\s?<(.+)>/', $recipient, $matches ) ) {
     449                    if ( count( $matches ) == 3 ) {
     450                        $recipient_name = $matches[1];
     451                        $recipient = $matches[2];
     452                    }
     453                }
     454                $phpmailer->AddBcc( trim($recipient), $recipient_name );
     455            } catch ( phpmailerException $e ) {
     456                continue;
     457            }
    420458        }
    421459    }
     
    456494    if ( !empty( $attachments ) ) {
    457495        foreach ( $attachments as $attachment ) {
    458             $phpmailer->AddAttachment($attachment);
     496            try {
     497                $phpmailer->AddAttachment($attachment);
     498            } catch ( phpmailerException $e ) {
     499                continue;
     500            }
    459501        }
    460502    }
     
    463505
    464506    // Send!
    465     $result = @$phpmailer->Send();
    466 
    467     return $result;
     507    try {
     508        $phpmailer->Send();
     509    } catch ( phpmailerException $e ) {
     510        return false;
     511    }
     512
     513    return true;
    468514}
    469515endif;
     
    689735    do_action('set_logged_in_cookie', $logged_in_cookie, $expire, $expiration, $user_id, 'logged_in');
    690736
    691     // Set httponly if the php version is >= 5.2.0
    692     if ( version_compare(phpversion(), '5.2.0', 'ge') ) {
    693         setcookie($auth_cookie_name, $auth_cookie, $expire, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN, $secure, true);
    694         setcookie($auth_cookie_name, $auth_cookie, $expire, ADMIN_COOKIE_PATH, COOKIE_DOMAIN, $secure, true);
    695         setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, COOKIEPATH, COOKIE_DOMAIN, $secure_logged_in_cookie, true);
    696         if ( COOKIEPATH != SITECOOKIEPATH )
    697             setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, SITECOOKIEPATH, COOKIE_DOMAIN, $secure_logged_in_cookie, true);
    698     } else {
    699         $cookie_domain = COOKIE_DOMAIN;
    700         if ( !empty($cookie_domain) )
    701             $cookie_domain .= '; HttpOnly';
    702         setcookie($auth_cookie_name, $auth_cookie, $expire, PLUGINS_COOKIE_PATH, $cookie_domain, $secure);
    703         setcookie($auth_cookie_name, $auth_cookie, $expire, ADMIN_COOKIE_PATH, $cookie_domain, $secure);
    704         setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, COOKIEPATH, $cookie_domain, $secure_logged_in_cookie);
    705         if ( COOKIEPATH != SITECOOKIEPATH )
    706             setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, SITECOOKIEPATH, $cookie_domain, $secure_logged_in_cookie);
    707     }
     737    setcookie($auth_cookie_name, $auth_cookie, $expire, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN, $secure, true);
     738    setcookie($auth_cookie_name, $auth_cookie, $expire, ADMIN_COOKIE_PATH, COOKIE_DOMAIN, $secure, true);
     739    setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, COOKIEPATH, COOKIE_DOMAIN, $secure_logged_in_cookie, true);
     740    if ( COOKIEPATH != SITECOOKIEPATH )
     741        setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, SITECOOKIEPATH, COOKIE_DOMAIN, $secure_logged_in_cookie, true);
    708742}
    709743endif;
     
    833867 */
    834868function check_admin_referer($action = -1, $query_arg = '_wpnonce') {
     869    if ( -1 == $action )
     870        _doing_it_wrong( __FUNCTION__, __( 'You should specify a nonce action to be verified by using the first parameter.' ), '3.2' );
     871
    835872    $adminurl = strtolower(admin_url());
    836873    $referer = strtolower(wp_get_referer());
Note: See TracChangeset for help on using the changeset viewer.