Search Posts:

Maildir migration from command line [linux]

# Scenario: migrating mail service from one server to another with different IPs
# during dns switch some mail arrived in an old server's mailbox
# If we are running a dns server, we must remove the example.com MX records
# If we are running example.com as postfix virtual domain, we must remove it from the virtual_mailbox_domains directive in main.cf
# If we are running plesk or cpanel or similar software we must deactivate mail service for the domain example.com through the control panel

# Move to unread mails folder
cd /path/to/mail@example.com/Maildir/new

# Send unread messages to the new server
for file in ./*; do sendmail mail@example.com < $file; sleep 2; done;