首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法用mailx发送邮件

无法用mailx发送邮件
EN

Ask Ubuntu用户
提问于 2020-11-23 01:59:22
回答 1查看 8.6K关注 0票数 3

有人能帮忙处理这个错误吗?:

代码语言:javascript
复制
mailx -s "test message" recipient@gmail.com Cc: This is a test message
cannot send message: Process exited with a non-zero status

当我试图使用命令行中的mailx时,我得到了这个。

EN

回答 1

Ask Ubuntu用户

回答已采纳

发布于 2020-11-25 12:07:51

我对您最好的建议是为此目的实际使用s-nail,这比在Ubuntu中提供的各种版本的mailx / bsd-mailx / heirloom-mailx等更加省事。特别是,s-nail可以直接发送到外部SMTP服务器(如Gmail),而无需增加应用程序的复杂性,例如后缀。

s-nail可以按以下方式安装:

代码语言:javascript
复制
sudo apt-get install s-nail

然后您需要创建一个配置文件并适当地设置权限:

代码语言:javascript
复制
touch ~/.mailrc
chmod 0600 ~/.mailrc

使用您最喜欢的文本编辑器打开此文件,并将以下信息粘贴到其中。注意我用'xxxxx‘标记的部分,您需要添加自己的详细信息(通常是用户名和密码):

代码语言:javascript
复制
#--------------------------------------------#
# Setting mailx version v14.9.15 for gmail   #
#--------------------------------------------#

# Testing syntax:
# echo "Testing, Testing, Testing" | s-nail -s "My test..." xxxx@gmail.com

# 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="xxxxxxxx@gmail.com"

# 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
# App Password here in the obvious places:

set mta=smtps://username:password@smtp.gmail.com:465
#--------------------------------------------#

我已经在我的Ubuntu20.04系统上设置了这个系统,它运行得非常完美。请参阅下面我已经运行了建议的测试电子邮件(注意,我已经咀嚼了测试电子邮件地址):

代码语言:javascript
复制
$ echo "Testing, Testing, Testing" | s-nail -s "My test..." xxxxx@gmail.com
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 is
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

希望这也适用于您的Ubuntu20.04系统!

Notes

  1. App密码:在现代,您需要为S创建应用程序密码,以便成功访问Gmail:https://support.google.com/accounts/answer/185833
  2. symlink :大多数Linux发行版实际上都会将S链接到mailx,因此命令mailx将调用s-nail,但在Ubuntu20.04中似乎并非如此。毫无疑问,这是可以手工完成的。
票数 6
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/1294523

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档