2

I've deployed many Google Apps accounts and have used imapsync a number of times to migrate accounts to Google Apps.

This time however, no matter what I try imapsync refuses to work claiming my credentials are incorrect - I've checked them time and time again and they are 100% correct.

On Ubuntu 12, built from source, my command is:

imapsync --host1 myserver.com --user1 user1@server1.com --password1 mypassword1 -ssl1 --host2 imap.gmail.com --user2 user2@googleappsdomain.com --password2 mypassword2 -ssl2 -authmech2 PLAIN

Full output from the command:

get options: [1]
PID is 21316
$RCSfile: imapsync,v $ $Revision: 1.592 $ $Date:
With perl 5.14.2 Mail::IMAPClient  3.35
Command line used:
/usr/bin/imapsync --debug --host1 myserver.com --user1 user1@server1.com --password1 mypassword1 -ssl1 --host2 imap.gmail.com --user2 user2@googleapps.com --password2 mypassword2 -ssl2 -authmech2 PLAIN
Temp directory is /tmp
PID file is /tmp/imapsync.pid
Modules version list:
Mail::IMAPClient     3.35
IO::Socket           1.32
IO::Socket::IP       ?
IO::Socket::INET     1.31
IO::Socket::SSL      1.53
Net::SSLeay          1.42
Digest::MD5          2.51
Digest::HMAC_MD5     1.01
Digest::HMAC_SHA1    1.03
Term::ReadKey        2.30
Authen::NTLM         1.09
File::Spec           3.33
Time::HiRes          1.972101
URI::Escape          3.31
Data::Uniqid         0.12

IMAPClient 3.35
Info: turned ON syncinternaldates, will set the internal dates (arrival dates) on host2 same as host1.
Info: will try to use LOGIN authentication on host1
Info: will try to use PLAIN authentication on host2
Info: imap connexions timeout is 120 seconds
Host1: IMAP server [SERVER1] port [993] user [USER1]
Host2: IMAP server [imap.gmail.com] port [993] user [USER2]
Host1: * OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE AUTH=PLAIN AUTH=LOGIN] Dovecot ready.
Host1: SERVER1 says it has CAPABILITY for AUTHENTICATE LOGIN
Host1: success login on [SERVER1] with user [USER1] auth [LOGIN]
Host2: * OK Gimap ready for requests from MY-VPS 
Host2: imap.gmail.com says it has CAPABILITY for AUTHENTICATE PLAIN
Failure: error login on [imap.gmail.com] with user [USER2] auth [PLAIN]: 2 NO [AUTHENTICATIONFAILED] Invalid credentials (Failure)

I have tried -authmech2 LOGIN as well which returns:

Host2: imap.gmail.com says it has NO CAPABILITY for AUTHENTICATE LOGIN
Failure: error login on [imap.gmail.com] with user [user2@googleappsdomain.com] auth [LOGIN]: 2 NO [AUTHENTICATIONFAILED] Invalid credentials (Failure)

If anyone can shed some light on this I would greatly appreciate it.

9
  • Perhaps that Google account has 2-factor authentication enabled and imapsync cannot cope with that? Aug 7 '14 at 4:47
  • Janne, unfortunately I checked and can confirm that 2-factor authentication is disabled. Thanks though!
    – Touff
    Aug 7 '14 at 5:00
  • Is IMAP enabled for that particular account in GMail/GoogleApps? Check from GMail interface by clicking the gear icon, then Settings --> Forwarding and POP/IMAP --> See if IMAP is enabled. Aug 7 '14 at 5:03
  • Janne, it is enabled.
    – Touff
    Aug 7 '14 at 5:16
  • Can you connect to that particular GoogleApps account with some e-mail client such as Thunderbird? Aug 7 '14 at 5:20
2

Double check the credentials, so give it a 200% check. Follow the Janne advice of checking the credentials via a standard client like Thunderbird or Outlook or manually (see below).

Take care of quoting issues with special characters in passwords, use single quotes surrounding 'passwords' and users 'values'.

imapsync ... --password2 'secret' 

Other point, --authmech2 PLAIN or --authmech2 LOGIN are useless with Gmail now since imapsync already uses them by default. If the login works with a classical email client then it definitively means it is a character/quoting issue in the values. You can check a manual login with ncat or telnet-ssl like in this example (the client part to type is "a LOGIN ..." then "b LOGOUT"):

ncat --ssl -C  imap.gmail.com 993
* OK Gimap ready for requests from 78.196.254.58 q1mb175739668wix
a LOGIN "gilles.lamiral@gmail.com" "secret" 
* CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST... ESEARCH
a OK gilles.lamiral@gmail.com Gilles Lamiral authenticated (Success)
b LOGOUT
* BYE LOGOUT Requested
b OK 73 good day (Success)

Also try to change the password if there are weird characters in it.

1
  • Checked, checked and re-checked. Also works with a normal e-mail client. If none of those authmech's work which one should one use?
    – Touff
    Aug 11 '14 at 19:27
2

After having the same problem, I've switched on "Access for less secure apps" which solved the problem.

https://www.google.com/settings/security/lesssecureapps?pli=1

I had the same error with Larch.

0
1

My (working) imapsync setup uses --authmech2 LOGIN for the GMail side of the connection. I remember having problems with passing my password on the command line, so I switched to reading the password from a file with: --passfile2 /path/to/imapsecret2

My Fedora 20 packaged imapsync reports the following modules:

Mail::IMAPClient     3.35
IO::Socket           1.36
IO::Socket::IP       0.30
IO::Socket::INET     1.33
IO::Socket::SSL      1.955
Net::SSLeay          1.55
Digest::MD5          2.53
Digest::HMAC_MD5     1.01
Digest::HMAC_SHA1    1.03
Term::ReadKey        2.30
Authen::NTLM         1.09
File::Spec           3.40
Time::HiRes          1.9726
URI::Escape          3.31
Data::Uniqid         0.12

It reports the connection to GMail like so:

Host2: imap.googlemail.com says it has NO CAPABILITY for AUTHENTICATE LOGIN
Host2: success login on [imap.googlemail.com] with user [user@googleappsdomain] auth [LOGIN]
1
  • Sgaduuw, thanks for tip - I tried it but it didn't work either.
    – Touff
    Aug 11 '14 at 22:01
0

Another blocking issue for me was that I had to add the account to migrate to a standard email client (thunderbird). Once I added the account and opened it in thunderbird, imapsync worked.

0

For those that have NORMAL PASSWORDS here is the proper syntax

imapsync --host1 mail.yourname.com --user1 joelawrence@frame-all.com \
  --password1 '$4Password' --ssl1 \
  --host2 mail.vlc3.com --user2 joelawrence@frame-all.com \
  --password2 '$4EPassword' --ssl2

The trick is wrapping you password in '' because we have special chars these days.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.