henix / blog

some notes
0 stars 0 forks source link

Linux 获取邮件到本地 #9

Closed henix closed 10 years ago

henix commented 11 years ago

getmail

https://wiki.archlinux.org/index.php/Backup_Gmail_with_getmail

启动速度太慢(1分钟,原因不明)

fetchmail -> procmail -> maildir

http://blog.wains.be/2008/03/19/backup-your-gmail-account-in-maildir-format-using-fetchmail/ http://www.daemonforums.org/showthread.php?t=5590 https://bbs.archlinux.org/viewtopic.php?id=128450 https://wiki.archlinux.org/index.php/Procmail

offlineimap

http://pbrisbin.com/posts/mutt_gmail_offlineimap https://wiki.archlinux.org/index.php/OfflineIMAP

软件太新,服务器的源里没有

henix commented 11 years ago

fetchmail -f fetchmailrc

poll imap.gmail.com
protocol IMAP
username "username@example.com"
password 'password'
folder 'INBOX'
fetchlimit 460
keep
ssl

mda "/usr/bin/procmail -m /home/henix/test.mail/procmailrc"

procmailrc

MAILDIR=$HOME/test.mail
LOGFILE=$HOME/test.mail/procmail.log

:0
INBOX/

目录结构:$HOME/test.mail/INBOX/{new,tmp,cur}

henix commented 11 years ago

目测 fetchmail 是获取一封后就把它标记为已读,以此来记录读取的位置的

henix commented 11 years ago

然后用 Scala 从文件中读取:

import java.io.FileInputStream
import javax.mail.internet.MimeMessage

val msg = new MimeMessage(null, new FileInputStream(filename))
henix commented 9 years ago

fetchmail 和 getmail 在判断邮件是否已读上的差异:

  1. fetchmail 完全使用邮件服务器的状态,并且读了一封邮件后会将邮件标记为已读 http://unix.stackexchange.com/questions/67254/how-to-stop-fetchmail-marking-messages-as-read
  2. getmail 貌似是看本地的文件系统中是否有这个文件来判断的