mailx smtp_如何在Linux中通过内部SMTP使用mailx / s-nail发送电子邮件

mailx smtp

How to Send Email from mailx Command in Linux Using Gmail’s SMTP introduces how to send email using heirloom mailx (or s-nail if you are using Ubuntu 18 or later or similar releases) command in Linux through Gmail’s SMTP which requires some configuration. On the other hand, there are many environments that do not require SSL/TLS/etc. One example is the SMTP server (smtp.ust.hk) for HKUST requires no authentication for sending email from IPs inside the campus network. In this tutorial, I will introduce how to send email using mailx through internal SMTP (using HKUST’s smtp server smtp.ust.hk as the example).

如何发送电子邮件从mailx的命令在Linux中使用Gmail的SMTP介绍了如何使用发送电子邮件祖传的mailx (或仲-钉子 ,如果你使用Ubuntu 18或更高版本,或者类似的版本)的命令的Linux通过Gmail SMTP这需要一些配置。 另一方面,有许多环境不需要SSL / TLS / etc。 一个示例是HKUST的SMTP服务器(smtp.ust.hk)不需要身份验证即可从园区网络中的 IP发送电子邮件。 在本教程中 ,我将介绍如何通过内部SMTP使用mailx发送电子邮件(以HKUST的smtp服务器smtp.ust.hk为例)。

There are at least two methods: using all-in-one command or putting configurations into profile. The all-in-one-command way needs no other configurations except the command line itself, while the way using configuration has a clearer command.

至少有两种方法:使用多合一命令或将配置放入配置文件。 “多合一命令”方式除命令行本身外,无需其他配置,而使用配置的方式具有更清晰的命令。

多合一命令 (All-in-one command)

This is an all-in-one command that sends email to $TO_EMAIL_ADDRESS . You need to also replace these $FROM_EMAIL_ADDRESS and $FRIENDLY_NAME variables with your email and name.

这是将电子邮件发送到$ TO_EMAIL_ADDRESS的多合一命令。 您还需要用您的电子邮件和姓名替换这些$ FROM_EMAIL_ADDRESS和$ FRIENDLY_NAME变量。

(use s-nail instead in releases without the heirloom mailx)

(在没有传家宝邮件的版本中使用s-nail

$ mailx -v -s "$EMAIL_SUBJECT" \
-S smtp=smtp://smtp.ust.hk \
-S from="$FROM_EMAIL_ADDRESS($FRIENDLY_NAME)" \
$TO_EMAIL_ADDRESS

mailx will read the email content from STDIN. Type in the email main content and input "Ctrl+d" to tell mailx you have finished the content. The mail will be sent out. You can also use pipes like:

mailx将读取来自STDIN的电子邮件内容。 输入电子邮件的主要内容,然后输入“ Ctrl + d”以告诉mailx您已完成内容。 邮件将被发送出去。 您还可以使用如下管道:

$ echo "The mail content" | mailx -v -s ...

使用配置文件 (Using configuration file)

If you use this configuration frequently, you man consider putting the configuration into mailx‘s configuration file ~/.mailrc.

如果您经常使用此配置,则可以考虑将该配置放入mailx的配置文件~/.mailrc

set smtp=smtp://smtp.ust.hk
set from="$FROM_EMAIL_ADDRESS($FRIENDLY_NAME)"

Then you can send email directly by:

然后,您可以通过以下方式直接发送电子邮件:

$ mailx -v -s "$EMAIL_SUBJECT" $TO_EMAIL_ADDRESS

翻译自: https://www.systutorials.com/sending-email-using-mailx-in-linux-through-internal-smtp/

mailx smtp

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值