開発環境:ubuntu 18.0.4
したいこと
fetchmailを用いてメールを取ってき,textProcessing.rbにメールの内容を入れ特定の処理を行い,csvファイルにFROM , 氏名 を取ってきたく思います。
まずはテキストファイルとして保存することから始めました。
fetchmailの設定内容について
set daemon 10800 defaults uidl no mimedecode no rewrite mda /home/name/process/textProcessing.rb # メールを渡すプログラムのフル>パス keep poll mail.example.jp protocol POP3 username example@example.jp password xxxxxxxx ssl
textProcessing.rbについて
ruby
1require 'mail' 2 3class GetMail 4 def initialize 5 dt = Time.now.strftime("%Y%m%d_%H%M%S%L") 6 @out_file = "/home/name/#{dt}.txt" 7 end 8 9 def execute 10 open(@out_file, "w") do |f| 11 mail = Mail.new($stdin.read) 12 f.puts "From: #{mail.from.first}" 13 f.puts "To: #{mail.to.first}" 14 f.puts "Date: #{mail.date}" 15 f.puts "Subject: #{mail.subject}" 16 f.puts "Body:\n#{mail.body.decoded.encode("UTF-8", mail.charset)}" 17 end 18 rescue => e 19 $stderr.puts "[#{e.class}] #{e.message}" 20 e.backtrace.each{|trace| $stderr.puts "\t#{trace}"} 21 exit 1 22 end 23end 24 25exit unless $0 == __FILE__ 26GetMail.new.execute
ですが、テキストファイルが排出してくれていません。
rubyについてまだ行い始めて1ヶ月なのでよくわかっていません。
ご助力のほどよろしくお願いします。。。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/07/26 08:13
2018/07/26 08:54 編集
2018/07/26 12:57
2018/07/27 00:40
2018/07/27 00:59
2018/07/27 01:55
2018/07/27 01:59
2018/07/27 02:04
2018/07/27 02:18
2018/07/27 02:30
2018/07/27 02:31
2018/07/27 05:34
2018/07/27 05:45
2018/07/27 07:29
2018/07/27 07:32
2018/07/27 07:36
2018/07/27 07:38
2018/07/27 07:44
2018/07/27 07:47
2018/07/27 08:08
2018/07/27 08:18
2018/07/27 08:38
2018/07/27 08:40