5 件 見つかりました。
[2008-01-05-2]と同様なnmhのsetupを他の環境で行った際のメモ。
まず make install でコケた。incコマンドをginstallする際のchmod -g mail -m 2755 で "ginstall: cannot change ownership" "Operation not permitted" と怒られた。自分しか使わないのでパーミッションの指定を無くして無理矢理installした。
次に上記メモで「で、~/.mh_profileに以下を設定した(抜粋。他に変更は施していない)。」とか書いてある。でも$HOMEにそんなもんできてないし、雛形っぽいのもどこにもない。もとの.mh_profileが何なのか一切触れていない自分の無能っぷりに立腹。
どうやらmh-installコマンドを打つと雛形を作成してくれる模様。打つと「どこのディレクトリに保存しますか」的なことを聞かれて、答えたら終わった。出来上がった.mh_profileを見てみると下記のようだった。
Path: Mailこれだけかい!しょうがないのでもう1行つけたして以下の.mh_profileを作成。
Path: Mail Inbox: mhInboxで下記のようにすると、Mail/mhInboxに数字だけファイルがちゃんとできた。
$ echo world | $HOME/usr/lib/rcvstore本当にこんなんでいいのだろうか。
単なる備忘録。
configure時pcreが無いとか言われたのでインストールした。
./configure --prefix=/home/myname/usr make make check make installこれをconfigureにわからせるために以下の環境変数を設定(see. http://www.courier-mta.org/FAQ.html)
export LDFLAGS="-L/home/myname/usr/lib" export CPPFLAGS="-I/home/myname/usr/include"そして以下で終わり。たぶん問題なし
./configure --prefix=/home/myname/usr
[2007-10-10-1]の続きみたいなもの。mh形式をサポートしていないmaildrop使用時に、如何にmh形式でメールを蓄積させるか、という話。
似たような事例の議論を見つけた。maildropに標準出力に吐いてもらい、それをコマンドに喰わせてmh形式に保存する、という方法は一緒。ただしコマンドとして、nmhというパッケージに含まれるrcvstoreを用いている。実際にやってみるとうまくいった。私の自作プログラムより、広く使われているパッケージのが安心なので、こっちに乗り換えることにする。顛末をメモ。
まずnmhを入手・展開し下記のようにインストールした。
$ ./configure --prefix=$HOME/usr $ make $ make installそしたらrcvstoreが~/usr/libにインストールされた。で、~/.mh_profileに以下を設定した(抜粋。他に変更は施していない)。
Path: Mail Inbox: mhInbox以上で終了。下記のようにしたがうまくメールが蓄積されているようである。
$ cat tmp.eml | ~/usr/lib/rcvstore +mymhtest # ~/Mail/mymhtest に格納された。 $ cat tmp.eml | ~/usr/lib/rcvstore # ~/Mail/mhInbox に格納された。.mailfilterは以下のような感じで。
if (/^From:.*my@mail\.address\.jp/:h)
to "| $HOME/usr/lib/rcvstore +mymhtest"
うまく動いてるっぽいけど、しばらく運用して様子見してみよう。| Op Wed, 20 Oct 2004 09:41:15 -0600 xxxx: | | >> Just for grins I had a look at Maildrop, which you suggested. At this | >> moment I can't see how I could make use of it, since it does not seem | >to> support MH-style mailfolders. And my e-mail program uses those... | > | >mh and nmh start as tiny programs you call from the shell, so using | >them with another MDA is usually as simple as having the MDA itself run | >something like"/usr/local/libexec/nmh/rcvstore +inbox". | | Could be something to look into. Thanks. | | >I'm surprised maildrop doesn't have built-in mh support, though. Are | >you sure about that? Maildrop definitely does NOT support mh folders, I've hacked around it for a few weeks, and then resolved to use rcvstore as a destination.
maildropを便利に使用している。これはメールを振り分け後Maildir形式かmbox形式で保存する。以下 man maildropfilterの記述の抜粋。
TO - DELIVER MESSAGE TO A MAILBOX
to expression
The to statement delivers the message to a mailbox. expression must
evaluate to a valid mailbox. A valid mailbox is either a mailbox file,
a maildir, or an external program (which includes forwarding to another
address).
(中略)
Otherwise, expression names the mailbox where maildrop delivers the
message. If expression is a directory, maildrop assumes that the
directory is a maildir directory. Otherwise, maildrop will deliver the
message to a file, formatted in traditional mailbox format. maildrop
will use either dot-locking, or flock()-locking when delivering the
message to the file.
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <dirent.h>
void log(const char*);
unsigned int LargestFilenameNumber(const char*);
int main(int argc, char* argv[]){
char c;
FILE *fp;
char fname[256];
int newfilenum;
const char* dirname = argv[1];
if(argc != 2){
log("invalid argument");
return -1;
}
newfilenum = LargestFilenameNumber(dirname)+1;
if(newfilenum == 0){
log("error in LargestFilenameNumber");
return -1;
}
if(dirname[strlen(dirname)-1] == '/') sprintf(fname, "%s%d", dirname, newfilenum);
else sprintf(fname, "%s/%d", dirname, newfilenum);
fp = fopen(fname, "w");
if(fp == NULL){
log("error in file opening");
return -1;
}
while(1){
c = fgetc(stdin);
if(c == EOF) break;
fputc(c, fp);
}
fclose(fp);
return 0;
}
unsigned int LargestFilenameNumber(const char* dirname){
DIR *dir;
unsigned int filenum, filenum_max;
char dummy;
char fname[256];
struct dirent *dp;
if((dir=opendir(dirname))==NULL) return -1;
filenum_max = 0;
while((dp = readdir(dir)) != NULL){
if((strcmp(dp->d_name, ".")==0) || (strcmp(dp->d_name, "..")==0)) continue;
// sscanf return value ex. "1.eml" => 2, "hoge" => 0, "67" => 1
if(sscanf(dp->d_name, "%u%c", &filenum, &dummy) != 1) continue;
filenum_max = filenum_max > filenum ? filenum_max : filenum;
}
closedir(dir);
return filenum_max;
}
void log(const char* str){
FILE *fp;
struct tm *st;
time_t t;
char month[][4] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
t = time(NULL);
st = localtime(&t);
fp = fopen("hiStdin2Mh_log", "a");
fprintf(fp, "%d %s %.2d: %.2d:%.2d:%.2d\n", st->tm_year+1900, month[st->tm_mon], st->tm_mday, st->tm_hour, st->tm_min, st->tm_sec);
fprintf(fp, "%s\n\n", str);
fclose(fp);
}
ChangeLog INDEX