Changeset 910
- Timestamp:
- 06/06/06 17:55:08
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/plagger/lib/Plagger/Plugin/Publish/Maildir.pm
r909 r910 11 11 use File::Find; 12 12 13 our $VERSION = '0. 2';13 our $VERSION = '0.3'; 14 14 15 15 sub register { … … 67 67 my $subject = $entry->title || '(no-title)'; 68 68 my $body = $self->templatize($context, $args); 69 my $from = 'plagger@localhost'; 69 $body = encode("utf-8", $body); 70 my $from = $cfg->{mailfrom} || 'plagger@localhost'; 71 my $id = md5_hex($entry->id_safe); 72 my $now = Plagger::Date->now(timezone => $context->conf->{timezone}); 70 73 my @enclosure_cb; 71 74 if ($self->conf->{attach_enclosures}) { … … 74 77 } 75 78 } 76 my $now = Plagger::Date->now(timezone => $context->conf->{timezone});77 79 $msg = MIME::Lite->new( 78 80 Date => $now->format('Mail'), … … 82 84 Type => 'multipart/related', 83 85 ); 84 $body = encode("utf-8", $body);85 86 $msg->attach( 86 87 Type => 'text/html; charset=utf-8', … … 91 92 $cb->($msg); 92 93 } 94 $msg->add('Message-Id', "<$id.plagger\@localhost>"); 93 95 $msg->add('X-Tags', encode('MIME-Header',join(' ',@{$entry->tags}))); 94 my $xmailer = "MIME::Lite (P ublish::Maildir/$VERSION in Plagger/$Plagger::VERSION)";96 my $xmailer = "MIME::Lite (Plagger/$Plagger::VERSION with Publish::Maildir/$VERSION)"; 95 97 $msg->replace('X-Mailer',$xmailer); 96 my $filename = md5_hex($entry->id_safe); 97 store_maildir($self, $context,$msg->as_string(),$filename); 98 store_maildir($self, $context,$msg->as_string(),$id); 98 99 $self->{msg} += 1; 99 100 } … … 174 175 175 176 sub store_maildir { 176 my($self,$context,$msg,$ file) = @_;177 my $filename = $ file.".plagger";177 my($self,$context,$msg,$id) = @_; 178 my $filename = $id.".plagger"; 178 179 find( 179 180 sub { 180 if ($_ =~ m!$ file.*!) {181 if ($_ =~ m!$id.*!) { 181 182 unlink $_; 182 183 $self->{update_msg} += 1; … … 185 186 $self->{path}."/cur" 186 187 ); 187 my $filename = $self->{path}."/new/".$filename; 188 open(FILE,">$filename"); 189 print(FILE $msg); 190 close(FILE); 188 $context->log(debug=> "writing: new/$filename"); 189 my $path = $self->{path}."/new/".$filename; 190 open my $fh, ">", $path or $context->error("$path: $!"); 191 print $fh $msg; 192 close $fh; 191 193 } 192 194 … … 204 206 folder: plagger 205 207 attach_enclosures: 1 208 mailfrom: plagger@localhost 206 209 207 210 =head1 DESCRIPTION
