Changeset 42
- Timestamp:
- 02/07/06 18:27:52
- Files:
-
- trunk/plagger/lib/Plagger/Plugin/Publish/Gmail.pm (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/plagger/lib/Plagger/Plugin/Publish/Gmail.pm
r37 r42 53 53 User => $route->{username}, 54 54 Password => $route->{password}, 55 Port => $route->{port} || 587, 55 56 ); 56 57 } else { … … 68 69 $out; 69 70 } 71 70 72 71 73 # hack MIME::Lite to support TLS Authentication … … 94 96 ### Create SMTP TLS client: 95 97 require Net::SMTP::TLS; 96 my $smtp = MIME::Lite::SMTP::TLS->new(@args) 97 or Carp::croak("Failed to connect to mail server: $!\n"); 98 my $smtp; 99 unless ($self->{__smtp}) { 100 $smtp = MIME::Lite::SMTP::TLS->new(@args) 101 or Carp::croak("Failed to connect to mail server: $!\n"); 102 $self->{__smtp} = $smtp; 103 } 98 104 $smtp->mail($from); 99 105 $smtp->to(@to_all); … … 103 109 $self->print_for_smtp($smtp); 104 110 $smtp->dataend(); 111 112 1; 113 } 114 sub DESTORY { 115 my $self = shift; 105 116 eval { 106 117 local $SIG{__WARN__} = sub { }; 107 $s mtp->quit;118 $self->{__smtp}->quit; 108 119 }; 109 110 120 # known error from Gmail SMTP 111 121 if ($@ && $@ !~ /An error occurred disconnecting from the mail server/) { 112 122 warn $@; 113 123 } 114 115 1;116 124 } 117 125
