Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mailx and Gmail nss config dir [closed]

Tags:

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.

like image 353
Jeff Avatar asked May 28 '13 18:05

Jeff


2 Answers

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.

like image 108
Jeff Avatar answered Sep 24 '22 14:09

Jeff


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/.

like image 26
penguinjeff Avatar answered Sep 23 '22 14:09

penguinjeff