Changeset 910

Show
Ignore:
Timestamp:
06/06/06 17:55:08
Author:
s_nobu
Message:

Add new parm and small changes.

Files:

Legend:

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

    r909 r910  
    1111use File::Find; 
    1212 
    13 our $VERSION = '0.2'; 
     13our $VERSION = '0.3'; 
    1414 
    1515sub register { 
     
    6767  my $subject    = $entry->title || '(no-title)'; 
    6868  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}); 
    7073  my @enclosure_cb; 
    7174  if ($self->conf->{attach_enclosures}) { 
     
    7477    } 
    7578  } 
    76   my $now = Plagger::Date->now(timezone => $context->conf->{timezone}); 
    7779  $msg = MIME::Lite->new( 
    7880    Date    => $now->format('Mail'), 
     
    8284    Type    => 'multipart/related', 
    8385  ); 
    84   $body = encode("utf-8", $body); 
    8586  $msg->attach( 
    8687    Type => 'text/html; charset=utf-8', 
     
    9192    $cb->($msg); 
    9293  } 
     94  $msg->add('Message-Id', "<$id.plagger\@localhost>"); 
    9395  $msg->add('X-Tags', encode('MIME-Header',join(' ',@{$entry->tags}))); 
    94   my $xmailer = "MIME::Lite (Publish::Maildir/$VERSION in Plagger/$Plagger::VERSION)"; 
     96  my $xmailer = "MIME::Lite (Plagger/$Plagger::VERSION with Publish::Maildir/$VERSION)"; 
    9597  $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); 
    9899  $self->{msg} += 1; 
    99100} 
     
    174175 
    175176sub store_maildir { 
    176   my($self,$context,$msg,$file) = @_; 
    177   my $filename = $file.".plagger"; 
     177  my($self,$context,$msg,$id) = @_; 
     178  my $filename = $id.".plagger"; 
    178179  find( 
    179180    sub { 
    180       if ($_ =~ m!$file.*!) { 
     181      if ($_ =~ m!$id.*!) { 
    181182        unlink $_; 
    182183        $self->{update_msg} += 1; 
     
    185186    $self->{path}."/cur" 
    186187  ); 
    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; 
    191193} 
    192194 
     
    204206      folder: plagger 
    205207      attach_enclosures: 1 
     208      mailfrom: plagger@localhost 
    206209 
    207210=head1 DESCRIPTION