关于linux:在Linux命令行发送电子邮件附件的两种方法

5次阅读

共计 636 个字符,预计需要花费 2 分钟才能阅读完成。

在 Linux 命令行发送邮件,对于系统管理员,能够附加备份文件、日志文件 / 零碎运行报告或任何相干信息,并将其发送到近程计算机,是一件十分有用的。
需要
本文应用 Centos7 操作系统。

须要有一个工作失常的邮件系统。本文将不介绍如何配置邮件服务器。

应用 mail 命令
装置 mailx 安装包

[root@localhost ~]# yum -y install mailx
装置实现,咱们能够应用上面发送带附件的邮件:

[root@localhost ~]# echo “Message Body Here” | mail -s “Subject Here” user@example.com -a anaconda-ks.cfg
其中的 -s:指定邮件主题。-a:增加附件。
也能够在文件中保留音讯内容,而后应用 mail 发送:

[root@localhost ~]# mail -s “Subject here” -t user@example.com -A anaconda-ks.cfg < message.txt
应用 mutt 命令
装置 mutt 安装包:

[root@localhost ~]# yum -y install mutt
装置实现,咱们能够应用上面发送带附件的邮件:

[root@localhost ~]# echo “Message Body Here” | mutt -s “Subject Here” -a anaconda-ks.cfg user@example.com
其中的 -s:指定邮件主题。-a:增加附件。

总结
你是否有其余办法能够从 Linux 终端发送带有附件的电子邮件?

正文完
 0