3

I am trying to send email using mailx using remote SMTP server (in my case it is office365 SMTP Server).

Here is the command:

# echo "THis is the Body of the email"  | mailx -v -s "This is email subject" -S smtp-use-starttls -S ssl-verify=ignore  -S smtp-auth=login -S smtp=smtp://smtp.office365.com:587 -S [email protected] -S [email protected] -S smtp-auth-password=user_password [email protected] -S nss-config-dir="/etc/pki/nssdb/"

And it fails with below error:

nss-config-dir=/etc/pki/nssdb/: No such file or directory
"/root/dead.letter" 11/339
Resolving host smtp.office365.com . . . done.
Connecting to 132.245.80.146 . . . connected.
220 BY2PR02CA0047.outlook.office365.com Microsoft ESMTP MAIL Service ready at Wed, 5 Nov 2014 10:08:22 +0000
>>> EHLO ip-10-0-1-10.us-west-2.compute.internal
250-BY2PR02CA0047.outlook.office365.com Hello [54.201.139.35]
250-SIZE 78643200
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
250-8BITMIME
250-BINARYMIME
250 CHUNKING
>>> STARTTLS
220 2.0.0 SMTP server ready
Missing "nss-config-dir" variable.
"/root/dead.letter" 11/339
. . . message not sent.

So the real error is nss-config-dir=/etc/pki/nssdb/: No such file or directory

Now, I do have a good directory with necessary certs and keys as needed by nss-config-dir option as below:

# ls -ld /etc/pki/nssdb/
drwxr-xr-x. 2 root root 4096 Aug 13  2013 /etc/pki/nssdb/

# ls -ltr /etc/pki/nssdb/
total 124
-rw-r--r--. 1 root root 65536 Jan 12  2010 cert8.db
-rw-r--r--. 1 root root 16384 Jan 12  2010 secmod.db
-rw-r--r--. 1 root root  9216 Jan 12  2010 cert9.db
-rw-r--r--. 1 root root 11264 Jan 12  2010 key4.db
-rw-r--r--. 1 root root 16384 Jan 12  2010 key3.db
-rw-r--r--. 1 root root   451 Jan  9  2013 pkcs11.txt

Here is the info about nss-config-dir from man mailx:

      A  directory  that contains the files certN.db to retrieve certificates, keyN.db to retrieve private keys, and secmod.db, where N is a digit.
      These are usually taken from Mozilla installations, so an appropriate value might be  ‘~/.mozilla/firefox/default.clm’.   Mailx  opens  these
      files  read-only  and  does  not  modify  them.   However,  if the files are modified by Mozilla while mailx is running, it will print a ‘Bad
      database’ message.  It may be necessary to create copies of these files that are exclusively used by mailx then.  Only applicable  if  S/MIME
      and SSL/TLS support is built using Network Security Services (NSS).

I also have the SElinux Disabled:

# sestatus
SELinux status:                 disabled

Question:

Why mailx command is saying nss-config-dir=/etc/pki/nssdb/: No such file or directory whne I have the necessary directory and key/cert files in it ?

Here is my environment info:

# uname -a
Linux ip-10-0-1-10.us-west-2.compute.internal 2.6.32-358.14.1.el6.x86_64 #1 SMP Mon Jun 17 15:54:20 EDT 2013 x86_64 x86_64 x86_64 GNU/Linux

# lsb_release -a
LSB Version:    :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: RedHatEnterpriseServer
Description:    Red Hat Enterprise Linux Server release 6.4 (Santiago)
Release:        6.4
Codename:       Santiago

# rpm -qa | grep mailx
mailx-12.4-6.el6.x86_64

3 Answers 3

3

I would suggest that the underlying reason for the failure is that that you have appended the -S nss-config-dir="/etc/pki/nssdb/" setting after a recipient delivery address, so it is being treated as a file-based target for delivery.

You can see this in your strace output provided in your answer:

stat("nss-config-dir=/etc/pki/nssdb/", 0x7fff7073a310) = -1 ENOENT (No such file or directory)

Notice that the stat is trying to access a file called nss-config-dir=/etc/pki/nssdb/, not the directory /etc/pki/nssdb/.

Try putting your recipient address at the end of the list, like this

echo "This is the body of the email" |
mailx -v -s "This is email subject" \
    -S smtp-use-starttls \
    -S ssl-verify=ignore \
    -S smtp-auth=login \
    -S smtp=smtp://smtp.office365.com:587 \
    -S [email protected] \
    -S [email protected] \
    -S smtp-auth-password=user_password \
    -S nss-config-dir="/etc/pki/nssdb/" \
    [email protected]
1

I do not know what the problem was. On Ubuntu 12.04 I tried above command without nss-config-dir option and it worked just fine. Here it the command:

# echo "THis is the Body of the email"  | mailx -v -s "This is email subject" -S smtp-use-starttls -S ssl-verify=ignore  -S smtp-auth=login -S smtp=smtp://smtp.office365.com:587 -S [email protected] -S [email protected] -S smtp-auth-password=user_password [email protected]

I have no idea why it is not working on RHEL. I ran strace on RHEL on this command but could not figure out the issue. strace gave below message:

stat("nss-config-dir=/etc/pki/nssdb/", 0x7fff7073a310) = -1 ENOENT (No such file or directory)

I do not know why this directory is not being detected at all even in strace :(

Also, On RHEL, omitting nss-config-dir is not an option as the command will fail immediately with below error:

Missing "nss-config-dir" variable.
"/root/dead.letter" 11/346
. . . message not sent.

However, On Ubuntu, nss-config-dir is not needed and the command ran fine.

Whatever, I am closing this topic as I can survive with Ubuntu.

1

MS has a buggy TLS implementation.

I was able to overcome it using Stunnel with the following config data:

[office365-smtp]
client = yes
accept = 192.168.100.25:25
connect = my-personal-id.protection.outlook.com:25
protocol = smtp
verify = 2
CAfile = ca-cert.pem
checkHost = my-personal-id.protection.outlook.com

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .