[英]Using fetchmail for one time email extraction from gmail
fetchmail
in terminal to extract e-mails from my gmail account.fetchmail
从我的 gmail 帐户中提取电子邮件。~/.fetchmailrc
with:~/.fetchmailrc
:poll imap.gmail.com protocol POP3
user "someuser@gmail.com" is oren here
password 'verysecretpassword'
(Of course with real username+password). (当然使用真实的用户名+密码)。
$ fetchmail
.$ fetchmail
。fetchmail: 6.3.26 querying imap.gmail.com (protocol POP3) at Mon 03 Feb 2020 14:34:46 IST: poll started
Trying to connect to <ADDRESS> ... connection failed.
Using Fetchmail使用 Fetchmail
It looks like the config is set to poll an IMAP server but then specifying POP3 protocol.看起来配置设置为轮询 IMAP 服务器,然后指定 POP3 协议。 Try something like this for the
~/.fetchmailrc
file:对
~/.fetchmailrc
文件尝试类似的操作:
set postmaster "local_user"
set daemon 600
poll pop.gmail.com with proto POP3
user 'gmail_user_name' there with password 'app_password' is local_user here options ssl fetchlimit 400
where:在哪里:
local_user
is some local account where undeliverable mail should go (the "last ditch effort" before failing permanently). local_user
是一些无法投递的邮件应该去的本地帐户(永久失败之前的“最后努力”)。gmail_user_name
is everything to the left of the @
in the email address. gmail_user_name
是电子邮件地址中@
左侧的所有内容。app_password
is a specially generated password that is restricted to the gmail application (go here: https://myaccount.google.com/ and click Security
, then app passwords
and generate a new app password) app_password
是一个专门生成的密码,仅限于 Gmail 应用程序(转到此处: https : app_password
并点击Security
,然后点击app passwords
并生成新的应用密码) What to do at this point will depend on your local setup.此时要做什么取决于您的本地设置。 Fetchmail will... fetch mail (clearly).... and then deliver it to the local machine's delivery system.
Fetchmail 将...获取邮件(显然)...然后将其发送到本地机器的发送系统。 If you have sendmail (a pretty safe bet), this might work:
如果您有 sendmail(一个非常安全的赌注),这可能有效:
$ fetchmail -d0 -avNk -m "/usr/sbin/sendmail -i -f %F -- %T" pop.gmail.com
Mail should start flowing in. Messages can be read using the mail
command or get the raw content from /var/mail/[username]
.邮件应该开始流入。可以使用
mail
命令读取mail
或从/var/mail/[username]
获取原始内容。 This might not get everything in one shot;这可能无法一蹴而就; it very likely won't if the address has accumulated even a small amount of history.
如果地址积累了少量历史记录,则很可能不会。 Let it finish and check that it worked as expected.
让它完成并检查它是否按预期工作。 If everything looks good, then it's time to start
fetchmail
as a daemon process and let it download the entire mailbox.如果一切看起来都不错,那么是时候将
fetchmail
作为守护进程启动并让它下载整个邮箱。 First, configure fetchmail
with appropriate polling interval and batch size settings 1 .首先,使用适当的轮询间隔和批量大小设置1配置
fetchmail
。
~/.fetchmailrc
by the line daemon 600
(ie. 10 minute polling interval).~/.fetchmailrc
由 line daemon 600
配置了轮询间隔(即 10 分钟轮询间隔)。fetchlimit 400
is set in the ~/.fetchmailrc
under the options
section in the poll pop.gmail.com
stanza.poll pop.gmail.com
节的options
部分下的~/.fetchmailrc
设置了轮询选项fetchlimit 400
。 This is the maximum number of messages to fetch per poll.-d0
switch .-d0
开关。 Fetchmail should start as a true daemon and continue to periodically download batches of messages until the whole mailbox is downloaded. Fetchmail 应该作为一个真正的守护进程启动,并继续定期下载批量邮件,直到下载整个邮箱。 You will need to remember to kill the daemon process if you don't want it to continue syncing until the next reboot.
如果您不希望它在下次重新启动之前继续同步,则需要记住终止守护进程。
Using Google Takeout使用 Google 外卖
You can do this super easy using Google Takeout .您可以使用Google Takeout轻松完成此操作。 Log in, click the "deselect" option at the top of the list, then scroll down to
Mail
and check just that.登录,单击列表顶部的“取消选择”选项,然后向下滚动到“
Mail
并进行检查。 You can choose to get the data in a .zip
or .tgz
file.您可以选择以
.zip
或.tgz
文件的形式获取数据。 They will send you an email when the archive is ready for download.当存档可供下载时,他们会向您发送电子邮件。 It is packaged in an
mbox
file but that is pretty straightforward to convert to other formats.它打包在一个
mbox
文件中,但转换为其他格式非常简单。
This is probably the easiest way to accomplish a one time export, and I think they have an option to set up a recurring export too.这可能是完成一次性导出的最简单方法,我认为他们也可以选择设置重复导出。 It probably isn't offering as much control compared to using the developer API directly, but it's a lot less hassle.
与直接使用开发人员 API 相比,它可能没有提供那么多的控制,但它的麻烦要少得多。
1: I believe Google has some rate limiting in place, so I am adding some steps to accommodate those limits. 1:我相信谷歌有一些速率限制,所以我添加了一些步骤来适应这些限制。 These are conservative values, since I don't know exactly what the limits are (or even for sure if they exist).
这些是保守值,因为我不确切知道限制是什么(甚至不确定它们是否存在)。 If you know more, or care to research it, adjust these values to whatever you think is best.
如果您了解更多信息,或想对其进行研究,请将这些值调整为您认为最好的值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.