Could someone kindly assist with this error?:
mailx -s "test message" Cc: This is a test message cannot send message: Process exited with a non-zero status I'm getting this when attempting to use mailx from the command-line.
41 Answer
My best advice to you is to actually use s-nail for this purpose which requires a lot less fussing around than the various versions of mailx / bsd-mailx / heirloom-mailx etc etc available under Ubuntu. In particular s-nail can send directly to external SMTP servers (such as Gmail) without the added complexity of applications such as Postfix.
s-nail can be installed as follows:
sudo apt-get install s-nail You then need to create a configuration file and set permissions appropriately:
touch ~/.mailrc chmod 0600 ~/.mailrc Open this file with you favourite text editor and paste the following information into it. Note the sections that I have mostly marked with 'xxxxx' where you will need to add your own details (usually username and password):
#--------------------------------------------# # Setting mailx version v14.9.15 for gmail # #--------------------------------------------# # Testing syntax: # echo "Testing, Testing, Testing" | s-nail -s "My test..." # Use v15.0 compatibility mode set v15-compat # See the whole process, especially for troubleshooting: set verbose # Essential setting: select allowed character sets set sendcharsets=utf-8,iso-8859-1 # and reply in the same charset used by sender: set reply-in-same-charset # Default directory where we act in (relative to $HOME) set folder=mail # My actual address obfuscated here: set from="" # Request strict TLL transport layer security checks set tls-verify=strict set tls-ca-file=/etc/ssl/certs/ca-certificates.crt set tls-ca-no-defaults set smtp-use-starttls set smtp-auth=login # When sending messages, wait until the Mail-Transfer-Agent finishes. # Only like this you will be able to see errors reported through the # exit status of the MTA (including the built-in SMTP one)! set sendwait # And of course put your own gmail username and # password here in the obvious places: set mta=smtps://username::465 #--------------------------------------------# I have set this up on my Ubuntu 20.04 system and it works flawlessly. See below where I have run the suggested test email (note I have munged the test email address):
andrew@ithaca:~$ echo "Testing, Testing, Testing" | s-nail -s "My test..." s-nail: P(seudo)R(andom)N(umber)G(enerator): *TLS RAND_* s-nail: Resolving host smtp.gmail.com:465 ... done s-nail: Connecting to 74.125.130.108:465 ... connected. s-nail: Certificate depth 2 s-nail: subject = /OU=GlobalSign Root CA - R2/O=GlobalSign/CN=GlobalSign s-nail: notBefore = Dec 15 08:00:00 2006 GMT s-nail: notAfter = Dec 15 08:00:00 2021 GMT s-nail: issuer = /OU=GlobalSign Root CA - R2/O=GlobalSign/CN=GlobalSign s-nail: Certificate depth 1 s-nail: subject = /C=US/O=Google Trust Services/CN=GTS CA 1O1 s-nail: notBefore = Jun 15 00:00:42 2017 GMT s-nail: notAfter = Dec 15 00:00:42 2021 GMT s-nail: issuer = /OU=GlobalSign Root CA - R2/O=GlobalSign/CN=GlobalSign s-nail: Certificate depth 0 s-nail: subject = /C=US/ST=California/L=Mountain View/O=Google LLC/CN=smtp.gmail.com s-nail: notBefore = Nov 3 07:37:59 2020 GMT s-nail: notAfter = Jan 26 07:37:59 2021 GMT s-nail: issuer = /C=US/O=Google Trust Services/CN=GTS CA 1O1 s-nail: Comparing subject_alt_name: need<smtp.gmail.com> is<smtp.gmail.com> s-nail: TLS certificate ok s-nail: TLS BLAKE2s256 fingerprint: 0C:F8:DA:33:CE:15:EA:7F:F6:8B:28:C1:95:33:A0:1D:01:B7:F3:D8:E2:7B:29:42:70:D6:4B:6A:6D:16:8A:CF s-nail: TLS connection using TLSv1.3 / TLS_AES_256_GCM_SHA384 andrew@ithaca:~$ Hopefully this will work on your Ubuntu 20.04 system as well!
Notes:
- Less secure..: You will need to allow 'less secure' apps access gmail for s-nail to access gmail successfully:
- Symlinks: Most Linux distros will actually symlink s-nail to mailx so the command
mailxwill calls-nailbut this does not appear to be the case under Ubuntu 20.04. Doubtless this could be done manually...