2つのサーバー間でメールを転送する

2つのサーバー間でメールを転送する

Ubuntu 14.04 で稼働しているサーバーが 2 台あります。両方に Postfix と Dovcote がインストールされています。メール サーバーは両方で正常に稼働しています。サーバー 1 からサーバー 2 にメールを転送したいのですが、手順を教えていただけますか。

答え1

「imapsync」スクリプトを使用してそれらを転送できます。これは、Google メールへの移行に使用したスクリプトです。これは、imap 対応の任意のメール サーバーで使用できます。

SERVER1=imap.source.com
SERVER2=imap.dest.com

#Uncomment to hide folder sizes
FAST="--nofoldersizes"

#Uncomment to do a dry run (no actual changes)
#DRY="--dry" 

#Uncomment to just sync folders (no messages)
#JUSTFOLDERS="--justfolders" 

#Uncomment to just connect (no syncs at all)
#JUSTCONNECT="--justconnect" 

#Set the path to your imapsync binary
imapsync=imapsync

#Users file
if [ -z "$1" ]
then
echo "No users text file given." 
exit
fi

if [ ! -f "$1" ]
then
echo "Given users text file \"$1\" does not exist" 
exit
fi

while IFS=';' read  u1 p1 u2 p2; do {

$imapsync --usecache --syncinternaldates --nosyncacls --tmpdir /var/tmp --host1 ${SERVER1} --user1 "$u1" --password1 "$p1" --host2 ${SERVER2} --port2 993 --user2 "$u2" --password2 "$p2" --ssl2 ${FAST} ${DRY} ${JUSTFOLDERS} ${JUSTCONNECT} --exclude "Sent|^Delet|Drafts|Spam|Calendar|Brouillons|^Calend|envoi|^Contacts|Flux|sirable|Flux RSS|^Historiqu|Infected|Journal|Junk|LinkedIn|Notes|Outbox|^Probl|supprim|Courrier ind&AOk-sirable" --regextrans2 "s,^&AMk-l&AOk-ments envoy&AOk-s$,[Gmail]/Messages envoy&AOk-s," --regextrans2 "s,^INBOX/,," --regextrans2 's{Sent Items$}{[Gmail]/Messages envoy&AOk-s}' --regextrans2 's{Sent Messages$}{[Gmail]/Messages envoy&AOk-s}' --regextrans2 's{&AMk-l&AOk-ments envoy&AOk-s$}{[Gmail]/Messages envoy&AOk-s}' --regextrans2 's{Éléments envoyés$}{[Gmail]/Messages envoy&AOk-s}'
}
done < $1

スクリプトを起動するためのコマンドラインは

./script.sh sample.txt

ここで、sample.txt は両方のサーバーの各ユーザーのアドレスとパスワードを含むファイルです。

[email protected];password1;[email protected];password2

関連情報