WordPress.org

Make WordPress Core

Changeset 17753


Ignore:
Timestamp:
04/28/11 18:16:01 (3 years ago)
Author:
ryan
Message:

Use exceptions with phpmailer to avoid headers already sent errors. fixes #17228

File:
1 edited

Legend:

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

    r17612 r17753  
    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 
     
    401401 
    402402    foreach ( (array) $to as $recipient ) { 
    403         $phpmailer->AddAddress( trim( $recipient ) ); 
     403        try { 
     404            $phpmailer->AddAddress( trim( $recipient ) ); 
     405        } catch ( phpmailerException $e ) { 
     406            continue; 
     407        } 
    404408    } 
    405409 
     
    411415    if ( !empty( $cc ) ) { 
    412416        foreach ( (array) $cc as $recipient ) { 
    413             $phpmailer->AddCc( trim($recipient) ); 
     417            try { 
     418                $phpmailer->AddCc( trim($recipient) ); 
     419            } catch ( phpmailerException $e ) { 
     420                continue; 
     421            } 
    414422        } 
    415423    } 
     
    417425    if ( !empty( $bcc ) ) { 
    418426        foreach ( (array) $bcc as $recipient) { 
    419             $phpmailer->AddBcc( trim($recipient) ); 
     427            try { 
     428                $phpmailer->AddBcc( trim($recipient) ); 
     429            } catch ( phpmailerException $e ) { 
     430                continue; 
     431            } 
    420432        } 
    421433    } 
     
    456468    if ( !empty( $attachments ) ) { 
    457469        foreach ( $attachments as $attachment ) { 
    458             $phpmailer->AddAttachment($attachment); 
     470            try { 
     471                $phpmailer->AddAttachment($attachment); 
     472            } catch ( phpmailerException $e ) { 
     473                continue; 
     474            } 
    459475        } 
    460476    } 
     
    463479 
    464480    // Send! 
    465     $result = @$phpmailer->Send(); 
    466  
    467     return $result; 
     481    try { 
     482        $phpmailer->Send(); 
     483    } catch ( phpmailerException $e ) { 
     484        return false; 
     485    } 
     486 
     487    return true; 
    468488} 
    469489endif; 
Note: See TracChangeset for help on using the changeset viewer.