mailOne
https://www.yamamototakashi.com/soft/mailone/download.html
条件にあったものを特定のフォルダにMH形式(eml)で保存しプログラム、バッチファイルを実行します。ISO-2022-JP形式のsubjectの条件判定と日本語が入ったメールbodyの文字化けを考慮する必要があります。
Sylpheed
https://sylpheed.sraoss.jp/ja/
シンプル、軽量かつ高機能で使いやすいメールソフトですが、MH形式で条件にあったものをバッチファイル、プログラムで実行でき特定の受信フォルダに保存できます
その他のソフトでは
・Becky!
・Thunderbird Mailbox Alert https://addons.thunderbird.net/ja/thunderbird/addon/mailbox-alert/
・OUTLOOK
以前はOUTLOOKもできていたようですがレジストリを変更すると元に戻るようです
https://blogs.technet.microsoft.com/outlooksupportjp/2017/12/29/rule_security/
レジストリキー : HKEY_CURRENT_USER\Software\Microsoft\Office\xx.0\Outlook\Security
名前: EnableUnsafeClientMailRules
種類: REG_DWORD
値: 1 (有効)
※レジストリ キーのパス中にある xx は以下の通り
Outlook 2010 の場合 : 14
Outlook 2013 の場合 : 15
Outlook 2016 の場合 : 16
Fetchmail & Procmail
unixで使用されているものです。MH形式(eml)で受信しprocmailで条件判定してプログラムを実行できます
https://linuxjm.osdn.jp/html/fetchmail/man1/fetchmail.1.html
cygwinにてwindowsで使用できます
php-mime-mail-parser
php-mime-mail-parserはメールパーサです。MH形式のものからfrom,to,subject,body,attatchを抽出できます。
これを使ってメールファイルから必要なものを抜き取ってバッチファイルで操作できます。PHPのインストールが必要です。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
[mailfrom.php] <?php require "d:/php/php726/vendor/autoload.php"; $input1 = $_SERVER['argv']][[1]]; $path = $input1; $Parser = new PhpMimeMailParser\Parser(); $Parser->setText(file_get_contents($path)); $addressesFrom = $Parser->getAddresses('from'); echo $addressesFrom[0]['address']; ?> 本文、件名は下記のように変更 $text = $Parser->getMessageBody('text'); echo $text; $subject = $Parser->getHeader('subject'); echo $subject; 添付ファイルは [mailattach.php] <?php require "d:/php/php726/vendor/autoload.php"; $input1 = $_SERVER['argv'][1]; $attach1 = $_SERVER['argv'][2]; $path = $input1; $Parser = new PhpMimeMailParser\Parser(); $Parser->setText(file_get_contents($path)); $attach_dir = $attach1; $include_inline = true; $Parser->saveAttachments($attach_dir ,[$include_inline]); $attachments = $Parser->getAttachments([$include_inline]); // Loop through all the Attachments if (count($attachments) > 0) { foreach ($attachments as $attachment) { echo 'Filename : '.$attachment->getFilename()."\n"; } } ?> |
CMAIL WRITER
CMAIL WRITERはsmtpクライアントでメールをコマンドラインで送信できます
https://www.vector.co.jp/soft/win95/net/se069973.html
http://espresso3389.hatenablog.com/entry/20080826/1219739382
メール受信したあとに返信するときに使用できます。オプションをつけるとMH形式のファイルを作成できます。
SMAIL
SMAILは 送信専用コマンドラインメールソフトです。仕事で使うには連絡が必要のようです。メール受信したあとに返信するときに使用できます
https://www.picolix.jp/disp2.html
fake sendmail
MH形式のメールをそのまま送信できます。メール受信したあとに転送するときに使用できます
https://www.glob.com.au/sendmail/
Mercury Mailもあります
http://www.pmail.com/
またXAMPPのインストール時に「Fake Sendmail」を選択できるようです。
これらのソフトを使用するとwindowsでメール受信の自動化を実現できます。
サンプル
Sylpheed
php-mime-mail-parser
CMAIL WRITERの組み合わせなど
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
::------------------------ ::sample.bat [infile] ::------------------------ ::------------------------ ::EMLからfrom抽出 ::------------------------ php mail2from.php %1>%~n1fromb.txt ::------------------------ ::fromファイル からBOM取る ::------------------------ nkf32 -w %~n1fromb.txt > %~n1from.txt ::------------------------ ::EMLからtitle抽出 ::------------------------ php mail2subject.php %1>%~n1subjectb.txt ::------------------------ ::titleファイル SJIS ::------------------------ nkf32 -s %~n1subjectb.txt > %~n1subjects.txt ::------------------------ ::EMLから本文抽出 ::------------------------ php mail2body.php %1> %~n1textb.txt ::------------------------ ::本文ファイルからBOM取る ::------------------------ nkf32 -s %~n1textb.txt > %~n1texts.txt ::------------------------ ::添付ファイル抽出 ::------------------------ md attach\%~n1 php mail2attach.php %1 attach\%~n1 ::------------------------ ::転送メール cmail.cfg ::------------------------ echo #自動作成>pdf2text.cfg echo -m %~n1texts.txt>>pdf2text.cfg echo -a snd@mail.com>>pdf2text.cfg echo -L rcv@mail.com/pass>>pdf2text.cfg echo -S +mail.jp>>pdf2text.cfg echo -x %cmailfo%sig.doc>>pdf2text.cfg for /F "tokens=1" %%a in ( %~n1from.txt ) do ( echo -t %%a>>pdf2text.cfg ) ::デリミタを空白にしない for /F "tokens=1 delims=" %%a in ( %~n1subjects.txt ) do ( echo -s "Conversion:%%a">>pdf2text.cfg ) ::------------------------ ::text変換 ::------------------------ for /r attach\%~n1 %%a in (.pdf) do ( pdftotext -layout -encShift-JIS "%%~fa" ) for /r attach\%~n1 %%a in (.pdf) do ( pdfimages -raw "%%~fa" "%%~fa" ) for /r attach\%~n1 %%a in (.tmp) do ( del "%%~fa" ) ::------------------------ ::ocr text変換 ::------------------- for /r attach\%~n1 %%a in (.jpg) do ( tesseract "%%~fa" "%%~fa" -l jpn ) for /r attach\%~n1 %%a in (.png) do ( tesseract "%%~fa" "%%~fa" -l jpn ) for /r attach\%~n1 %%a in (.gif) do ( tesseract "%%~fa" "%%~fa" -l jpn ) ::---------------- for /r attach\%~n1 %%a in (.) do ( echo -f "%%~fa">>pdf2text.cfg ) :: ::------------------------ ::転送メール ::------------------------ cmail -C pdf2text.cfg del /q attach\%~n1 rd attach\%~n1 del %~n1subjectb.txt del %~n1subjects.txt del %~n1fromb.txt del %~n1from.txt del %~n1textb.txt del %~n1texts.txt |
参考
winmail.datのデコード
ytnef https://github.com/Yeraze/ytnef
tnef https://github.com/verdammelt/tnef
pdfのテキスト化
pdftotext.exe pdfimages.exe http://www.xpdfreader.com/download.html
ocr https://opensource.google/projects/tesseract
かなふり
MeCab https://taku910.github.io/mecab/
KAKASI http://kakasi.namazu.org/index.html.ja]