有人可以帮助解决这个错误吗?:
mailx -s "test message" [email protected] Cc: This is a test message
cannot send message: Process exited with a non-zero status
我在尝试从命令行使用 mailx 时遇到了这个问题。
我对您的最佳建议是实际s-nail
用于此目的,与mailx / bsd-mailx / heirloom-mailx
Ubuntu 下可用的各种版本的etc 等相比,它需要的麻烦要少得多。特别是s-nail
可以直接发送到外部 SMTP 服务器(例如 Gmail),而无需增加 Postfix 等应用程序的复杂性。
s-nail
可以安装如下:
sudo apt-get install s-nail
然后,您需要创建一个配置文件并适当地设置权限:
touch ~/.mailrc
chmod 0600 ~/.mailrc
使用您喜欢的文本编辑器打开此文件并将以下信息粘贴到其中。请注意我主要用“xxxxx”标记的部分,您需要在其中添加自己的详细信息(通常是用户名和密码):
#--------------------------------------------#
# Setting mailx version v14.9.15 for gmail #
#--------------------------------------------#
# Testing syntax:
# echo "Testing, Testing, Testing" | s-nail -s "My test..." [email protected]
# 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="[email protected]"
# 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:[email protected]:465
#--------------------------------------------#
我已经在我的 Ubuntu 20.04 系统上设置了它,它运行完美。请参阅下面我在哪里运行建议的测试电子邮件(注意我已经修改了测试电子邮件地址):
andrew@ithaca:~$ echo "Testing, Testing, Testing" | s-nail -s "My test..." [email protected]
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:~$
希望这也适用于您的 Ubuntu 20.04 系统!
笔记:
mailx
将调用s-nail
但这并不似乎是Ubuntu的20.04之下的情况。毫无疑问,这可以手动完成...本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句