通过 CLI 在“公司模式”下从 office365 下载电子邮件

通过 CLI 在“公司模式”下从 office365 下载电子邮件

这是我在此网站上的第一篇文章,所以如果问题不清楚或者可能已经得到解答,请耐心等待(我找了好几天,但没有找到)

情况:我需要从商务电子邮件地址(例如:my.name@my_company.com)下载整个邮箱。电子邮件位于 office365 中,授权是公司 IT 部门控制的 Active Directory。:-)

我尝试使用 OFFLINEIMAP,它工作得很好,但到了一定程度,有些文件夹名称在 OFFLINEIMAP 看来有点“越界”了 :) 当然,这可以通过更改导致问题的文件夹名称来解决,但这些文件夹的数量似乎更多。现在可能是时候说了,有问题的邮箱大约有 37GB,包含大量子文件夹...

你们这些聪明物种中有人曾经用其他方法来做到这一点吗?!?

MUTT 可以登录邮箱,但是我该如何编写脚本才能成功,以便所有电子邮件都存储在我的硬盘上?

欢迎任何解决方案:)

答案1

好吧 - 我找到答案了!!!:) 记住,我只想下载电子邮件 - 而不是将任何内容上传到邮箱,或更改任何内容...我发现 MBSYNC 可以为我完成这项工作:)

sudo apt-get 安装 mbsync

vi ~/.mbsyncrc

粘贴:

IMAPAccount gmail
# Address to connect to
Host TheEmailServer...
User MyUserName4TheMailBox
Pass MyPassWord4TheMailBox
UseIMAPS yes
#SSLType IMAPS
#SSLVersion TLSv1.2
CertificateFile /etc/ssl/certs/ca-bundle.crt
PipelineDepth 1
# To store the password in an encrypted file use PassCmd instead of Pass
# PassCmd "gpg2 -q --for-your-eyes-only --no-tty -d ~/.mailpass.gpg"
#
# Use SSL
# AuthMechs *
# SSLType IMAPS
# SSLVersions TLSv1 TLSv1.1 TLSv1.2
# The following line should work. If get certificate errors, uncomment the two following lines and read the "Troubleshooting" section.
#CertificateFile /etc/ssl/certs/ca-certificates.crt
#CertificateFile ~/.cert/imap.gmail.com.pem
#CertificateFile ~/.cert/Equifax_Secure_CA.pem

IMAPStore gmail-remote
Account gmail

MaildirStore gmail-local
#Subfolders Verbatim
# The trailing "/" is important
Path ~/.mail/my_local_mailbox_folder/
#Inbox ~/.mail/didnt_work_for_me

Channel gmail
Master :gmail-remote:
Slave :gmail-local:
# Exclude everything under the internal [Gmail] folder, except the interesting folders
#Patterns * ![Gmail]* "[Gmail]/Sent Mail" "[Gmail]/Starred" "[Gmail]/All Mail"
# Or include everything
Patterns *
# Automatically create missing mailboxes, both locally and on the server
Create Both
# Save the synchronization state files in the relevant directory
Sync Pull
SyncState *

然后运行“mbsync gmail”,其中“gmail”是上面 ~/.mbsyncrc 中的名称

然后等待所有电子邮件到达:)

注意:我花了几天的时间才完成所有操作,并且我不得不重新启动同步几次:)

如果它对您有用,请不要忘记“喜欢”它:)

相关内容