Mailx and Gmail nss config dir

36,636

Solution 1

Thank you for this it gave me a way to find an even better solution. Supposedly these keyN.db and certN.db are databases of trusted certificate authorities.

I did a simple

find / -name "cert*.db"

to find where on my system has the keyN.db and certN.db files on my system (Fedora 20).
I found them under /etc/pki/nssdb/.

Solution 2

Solved it!

There are 2 ways you can go about solving this.

  1. Go over here and follow user ndasusers answer. It will both create the keyN.db and certN.db files you need but also another one GMail SSL certificate that will solve another potential problem.
  2. Or you can just copy the keyN.db and certN.db into a folder (/etc/ssl/cert maybe) and direct mail.rc there like so:

    account gmail {
        set smtp=smtps://smtp.gmail.com:587
        set smtp-auth=login
        set [email protected]
        set smtp-auth-password=PASSWORD
        set ssl-verify=ignore
        set nss-config-dir=/etc/ssl/cert
    }
    

Make sure you have permission to access those files if you are not root user, that buggered me up for a good while.

Share:
36,636

Related videos on Youtube

Jeff
Author by

Jeff

Updated on July 09, 2022

Comments

  • Jeff
    Jeff almost 2 years

    I am trying to send mail from a Linux command line using the mailx command. I can send from my local domain no problem but I want to set up mail to send from my Gmail account as well as receive mail sent to my Gmail account.

    After configuring my mail.rc like so:

    account gmail {
    set smtp=smtps://smtp.gmail.com:587
    set smtp-auth=login
    set [email protected]
    set smtp-auth-password=PASSWORD
    set ssl-verify=ignore
    }
    

    I would get the error:

    Resolving host smtp.gmail.com . . . done.
    Connecting to 74.125.25.109 . . . connected.
    Missing "nss-config-dir" variable.
    "/home/USERNAME/dead.letter" 11/354
    . . . message not sent.
    

    After looking up what the "nss-config-dir" was here, I located the certN.db and keyN.db files and added that to my mail.rc like so:

    account gmail {
    set smtp=smtps://smtp.gmail.com:587
    set smtp-auth=login
    set [email protected]
    set smtp-auth-password=PASSWORD
    set ssl-verify=ignore
    set nss-config-dir=/home/USER/.mozilla/firefox/LOCATION.default
    }
    

    now when I try to send mail using this command:

    echo "sent from gmail account" | mailx -v -A gmail -s "Command line mail" [email protected]
    

    I get this:

    Resolving host smtp.gmail.com . . . done.
    Connecting to 74.125.25.108 . . . connected.
    COMMENT-->then it waits there for about 5 mins then spits out this:
    SSL/TLS handshake failed: Unknown error -5938.
    "/home/USER/dead.letter" 11/354
    . . . message not sent.
    

    Does anyone know how to either:
    A) Set up mailx/mail.rc to access Gmail but ignore needing the nss-config-dir BS?
    B) Set up mailx/mail.rc so that the nss-config-dir actually works?
    C) Set up mailx/mail.rc to access Gmail in another way(POP maybe -don't know if that's an option, haven't looked into it?)

    Any help would be super appreciated.

  • k_o_
    k_o_ almost 9 years
    The directory of nss is /etc/pki/nssdb/. This can also be used to point to nss-config-dir.
  • Mike Purcell
    Mike Purcell over 8 years
    +1 to @k_o_ . For CentOS users, you should use /etc/pki/nssdb as /etc/pki is the default location for anything cert related, and includes a nssdb dir.