Changeset 236

Show
Ignore:
Timestamp:
03/02/06 13:51:32
Author:
miyagawa
Message:

Gmail: do POP before SMTP only once

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plagger/lib/Plagger/Plugin/Publish/Gmail.pm

    r191 r236  
    1313our %TLSConn; 
    1414 
     15sub rule_hook { 'publish.feed' } 
     16 
    1517sub register { 
    1618    my($self, $context) = @_; 
    1719    $context->register_hook( 
    1820        $self, 
     21        'publish.init' => \&initialize, 
    1922        'publish.feed' => \&notify, 
    2023    ); 
     24} 
     25 
     26sub initialize { 
     27    my($self,$context) = @_; 
     28 
     29    # authenticatE POP before SMTP 
     30    if (my $conf = $self->conf->{pop3}) { 
     31        require Net::POP3; 
     32        my $pop = Net::POP3->new($conf->{host}); 
     33        if ($pop->login($conf->{username}, $conf->{password})) { 
     34            $context->log(info => 'POP3 login succeed'); 
     35        } else { 
     36            $context->log(error => 'POP3 login error'); 
     37        } 
     38        $pop->quit; 
     39    } 
    2140} 
    2241 
     
    4867        Data => encode("utf-8", $body), 
    4968    ); 
    50  
    51     # POP before SMTP 
    52     if ($cfg->{pop3}) { 
    53         require Net::POP3; 
    54         my $pop = Net::POP3->new($cfg->{pop3}->{host}); 
    55         if ($pop->login($cfg->{pop3}->{username}, $cfg->{pop3}->{password})) { 
    56             $context->log(info => 'POP3 login succeed'); 
    57         } else { 
    58             $context->log(info => 'POP3 login error'); 
    59         } 
    60         $pop->quit; 
    61     } 
    6269 
    6370    my $route = $cfg->{mailroute} || { via => 'smtp', host => 'localhost' };