Mutt not working due to "gnutls_handshake: A TLS packet with unexpected length was received." error

Solution 1:

Unfortunately this can be a problem with Mutt and its use of gnutls, as can be seen from the Mutt mailing lists, however there are some solutions.

It is worth removing the header files from .mutt/cache/headers because they can sometimes cause problems. I also note that in your .muttrc you do not have a mailboxes line. I use gmail in Mutt and have the following in my .muttrc (though yours may differ):

mailboxes +INBOX +archive +sent +drafts +spam +trash

I mention this because at Launchpad this error was discussed and someone mentioned that specifying only the correct mailboxes solved his problem.

Comparing your .muttrc to mine in general reveals no other differences, and Mutt and gmail are working for me with almost identical settings.


However, if these suggestions do not solve your problem, it is possible to build Mutt from source and ensure that you build it with openssl support, so you can use openssl instead of gnutls. I note that in your second Pastebin, your Mutt has indeed been built with gnutls, as your debug reveals:

-USE_SSL_OPENSSL  +USE_SSL_GNUTLS

Here - means without that attribute and + means with that attribute.

So, before we start building, purge the currently installed mutt:

sudo apt-get purge mutt

and then get the dependencies with

sudo apt-get build-dep mutt

It is fine to use build-dep here as the latest version of mutt (at this time of writing) doesn't require any newer libraries than those fetched with build-dep.

You will also need to make sure you enter:

sudo apt-get install openssl libsasl2-modules libssl-dev libssl1.0.0

Now download the latest source code from the official site (which is 1.5.21 at time of writing) and then verify the appropriate gpg signature, and cd to the downloaded file and unpack the source code with

tar xzvf mutt-1.5.21.tar.gz 

Then pass these extra options to configure (we need to include the other options as well as ssl as imap and smtp support and other things are not compiled in by default):

./configure --enable-pop --enable-imap --enable-smtp --with-ssl --enable-hcache --with-gss --with-sasl --enable-debug --enable-gpgme

Then proceed to build and then install the program with

make 
sudo make install or sudo checkinstall

The build only takes a few moments and it should allow you to use Mutt again. It is probably a good idea to clear the header cache (as I detailed much further above) before you run the new program. It will use ssl automatically as there is now no tls support built in.

A screenshot from the newly compiled program (showing some older, non-personal emails):

enter image description here