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

13,949

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

Share:
13,949

Related videos on Youtube

Tim
Author by

Tim

Hi, My name is Vinit Kumar, and I'm a Software Engineer. I am mainly interested in building the scalable backend in Django, Python, Node, Go, Tooling, Vim, and Coffee. In my personal website, you will find my thoughts and musings about a range of topics. My strength is in coming up with simple solutions to difficult problems. I especially enjoy reading books and spending time with my family. Currently, I lead the development of multi-tenant CMS at SocialSchools B.V. I have 9 years of experience writing backend in Django for a successful product and numerous service projects. I do plenty of OSS work, and you find some interesting projects at my GitHub profile, vinitkumar.

Updated on September 18, 2022

Comments

  • Tim
    Tim almost 2 years

    I am expecting lots of problem trying to make mutt work in Ubuntu 12.04. Here is my .muttrc : http://paste.ubuntu.com/1273585/

    Here is the bug I am getting when i tried to connect. gnutls_handshake: A TLS packet with unexpected length was received.

    Do anyone knows a workaround to fix this error.If so please suggest it asap.

    Many Thanks in Advance!

    For debug here is the output of my mutt -v: http://paste.ubuntu.com/1273590/

    • mfisch
      mfisch over 11 years
      Are you on quantal?
    • Tim
      Tim over 11 years
      No, Ubuntu 12.04!
    • mfisch
      mfisch over 11 years
      I thought it was a 12.10 TLS issue that was fixed a couple days back, but I guess not, sorry.
    • yves Baumes
      yves Baumes about 9 years
      I had the exact same issue today... And the answer on this page did not help. But the answer here : unix.stackexchange.com/questions/66560/… solved my problem.