Learning and Sharing
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
No Result
View All Result

Imapsync Exchange Fails with BAD Command Received in Invalid State

July 28, 2023
in Blog, imapsync
0
ADVERTISEMENT

Table of Contents

BAD Command Received in Invalid State

imapsync \
--host1 mail.duybao.me \
--user1 [email protected] \
--password1 $password1 \
--nosslcheck \
--notls1 \
\
--host2 mail.duykhang.me \
--user2 [email protected] \
--password2 $password2 \
--justlogin

In some cases, you got this error when trying to migrate emails from Exchange Server using imapsync.

Host1 IP address: 20.232.97.85 Local IP address: 10.10.5.50
Host1 banner: * OK The Microsoft Exchange IMAP4 service is ready.
Host1 capability before authentication: IMAP4 IMAP4rev1 LOGINDISABLED STARTTLS UIDPLUS 
Host1 info: authmech [LOGIN] user [[email protected]] authuser [] IsUnconnected []
Host1 failure: Error login on [mail.duybao.me] with user 
[[email protected]] auth [LOGIN]: 2 BAD Command received in Invalid state.
Host1: failed login on [mail.duybao.me] with user [[email protected]] auth [LOGIN]

You got it because the Exchange server doesn’t have a valid certificate or using a self-certificate.

EgDBv3VouPwWq3wKMjV2eEHgTWJjMiMaor8L3TW7C4PUPVeaVsfXUuxNiiRs

To fix it, you need to change the authentication for IMAP protocol to Basic Authentication on your Exchange Server. The steps are shown in the below screenshot.

Tx5aQp1xIwxPUr4o1JzNHlXbBM8qMPz0kIGtPeih0dkpL99WfbpqVonMuwHg

Changing the login method requires restart the IMAP services. You can restart them from services.msc or can do it using PowerShell:

Get-Service *imap* | Restart-Service

Because the Exchange server doesn’t have a valid certificate, so you need to add these options in the migration command.

imapsync \
--host1 mail.duybao.me \
--user1 [email protected] \
--password1 $password1 \
--nosslcheck \
--notls1 \
\
--host2 mail.duykhang.me \
--user2 [email protected] \
--password2 $password2 \
--justlogin

The error should be gone then imapsync can be authenticated for migration.

Host1: IMAP server [mail.duybao.me] port [143] user [[email protected]]
Host2: IMAP server [mail.duykhang.me] port [143] user [[email protected]]
Host1: connecting and login on host1 [mail.duybao.me] port [143] with user [[email protected]]
Host1 IP address: 20.232.97.85 Local IP address: 10.0.0.4
Host1 banner: * OK The Microsoft Exchange IMAP4 service is ready.
Host1 capability before authentication: IMAP4 IMAP4rev1 AUTH=PLAIN AUTH=NTLM AUTH=GSSAPI STARTTLS
Host1: success login on [mail.duybao.me] with user [[email protected]] auth [LOGIN] or [LOGIN]
Host2: connecting and login on host2 [mail.duykhang.me] port [143] with user [[email protected]]
Host2 IP address: 20.127.32.166 Local IP address: 10.0.0.4
Host2 banner: * OK IMAPrev1
Host2 capability before authentication: IMAP4 IMAP4rev1 CHILDREN IDLE QUOTA SORT ACL
Host2: success login on [mail.duykhang.me] with user [[email protected]] auth [LOGIN] or [LOGIN]
Host1: state Authenticated
Host2: state Authenticated
5/5 - (1 vote)
Previous Post

How to Fix the Repository CD-ROM Does not Have a Release File in Ubuntu

Next Post

PuTTY Fatal Error No Supported Authentication methods available (server sent: publickey)

Related Posts

Running Hyper-V and VMware Workstation on The Same Machine

August 15, 2024

How to Uninstall All Autodesk Products At Once Silently

July 29, 2024
Ftr5

How to Uninstall the Autodesk Genuine Service on Windows

July 29, 2024
Ftr19

How to Fix Windows Cannot Read the ProductKey From the Unattend Answer File in VirtualBox

July 26, 2024
Ftr25

How to Update Windows Terminal in Windows 10/11

July 26, 2024

How to Disable The Beep Sound in WSL Terminal on Windows

July 26, 2024

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • How To Turn On uBlock Origin Extension in Chrome (2025)
  • Images Hidden Due To Mature Content Settings In CivitAI
  • Azure OpenAI vs Azure AI Hub, How to Choose the Right One for Your Needs

Categories

Stay in Touch

Discord Server

Join the Discord server with the site members for all questions and discussions.

Telegram Community

Jump in Telegram server. Ask questions and discuss everything with the site members.

Youtube Channel

Watch more videos, learning and sharing with Leo ❤❤❤. Sharing to be better.

Newsletter

Join the movement and receive our weekly Tech related newsletter. It’s Free.

General

Microsoft Windows

Microsoft Office

VMware

VirtualBox

Technology

PowerShell

Microsoft 365

Microsoft Teams

Email Servers

Copyright 2025 © All rights Reserved. Design by Leo with ❤

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory