at_yasu's blog

ロード的なことを

追記3 wp-mailをApopに対応 (応急処置)

忘れてた。wp-mail.zipや、デフォルトのwp-mail.phpでは、APOP認証に対応していない事を。


これはあくまで応急処置です。WordPressをアップデートした場合、使い物にならなくなる可能性があるのでご注意を。以下パッチ。

Version: WordPress2.1.2 のパッチ

--- wp-mail.php.dist    Tue Mar 20 00:50:24 2007
+++ wp-mail.php Tue Mar 20 00:52:19 2007
@@ -15,8 +15,14 @@
        wp_die($pop3->ERROR);
 
 $count = $pop3->login(get_option('mailserver_login'), get_option('mailserver_pass'));
-if (0 == $count) wp_die(__('There doesn’t seem to be any new mail.'));
+if (0 == $count) {
 
+  // Enable the APOP Authority.
+  $pop3->ALLOWAPOP = TRUE;
+  $count = $pop3->apop(get_option('mailserver_login'), get_option('mailserver_pass'));
+  if (0 == $count)
+    wp_die(__('There doesn’t seem to be any new mail.'));
+}
 
 for ($i=1; $i <= $count; $i++) :
 

Version: http://cafelog.net/files/wp-mail.zip のパッチ

--- wp-mail.php.dist    2004-07-18 23:18:02.000000000 +0900
+++ wp-mail.php 2007-03-20 00:59:02.000000000 +0900
@@ -31,7 +31,14 @@
 endif;
 
 $count = $pop3->login(get_settings('mailserver_login'), get_settings('mailserver_pass'));
-if (0 == $count) die("'There doesn't seem to be any new mail.");
+if (0 == $count) {
+  
+  // Enable the Apop authority.
+  $pop3->ALLOW_APOP = TRUE;
+  $count = $pop3->apop(get_settings('mailserver_login'), get_settings('mailserver_pass'));
+  if (0 == $count)
+    die("'There doesn't seem to be any new mail.");
+}
 
 for ($i=1; $i <= $count; $i++)
 {

しかし、formatting.phpのwp_iso_descramblerに"I'm afraid"と書くのはいかがな物か。良い仕事してるんだから、自信もってよ。

気休め程度だけど、こんな感じにしたらどうかしら。

// used by wp-mail to handle charsets in email subjects
function wp_iso_descrambler($string) {
  /* this may only work with iso-8859-1, I'm afraid */
//  if (!preg_match('#\=\?(.+)\?Q\?(.+)\?\=#i', $string, $matches)) {
//   return $string;
//  } else {
    $subject = '';
    if (!function_exists('mb_decode_mimeheader')) {
      $subject = str_replace('_', ' ', $matches[2]);
      /*    $subject = preg_replace('#\=([0-9a-f]{2})#ei', "chr(hexdec(strtolower('$1')))", $subject); */
      $subject = preg_replace('#\=([0-9a-f]{2})#i', "$1", $subject);
      $subject = chr(hexdec(strtolower($subject)));
    }
    else {
      // Japanese mail.
      $subject = mb_decode_mimeheader(preg_replace("/=\?([^\?]+)\?/e",
                                                  "'=?'.strtoupper('\\1').'?'",
                                                  $string));
    }
    return $subject;
//  }
}

にしても、今日はえらい書くな、わし・・・