linux命令之mail
linux命令mail是用来发送邮件
mail -s "Subject" EmailAddress < EmailMessage
参数 | 说明 |
-s | 指定邮件主题Subject |
EmailAddress | 指定邮件地址 |
EmailMessage | 指定邮件内容 |
1.安装sendmail/mailx
命令:
yum install sendmail mailx -y
- [root@rhel77 ~]# yum install sendmail mailx -y
- Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
- This system is not registered with an entitlement server. You can use subscription-manager to register.
- Package sendmail-8.14.7-5.el7.x86_64 already installed and latest version
- Package mailx-12.5-19.el7.x86_64 already installed and latest version
- Nothing to do
- [root@rhel77 ~]#
2.QQ邮箱获取授权码
-->登录QQ邮箱,点击“设置”
-->点击“账号”,切换到账号详情页面
-->在账号页面往下拉,可以看到“POP3/IMAP/SMTP/Exchange/CardDAV/CalDAV服务”,在“服务状态:服务已关闭”项,点击“开启服务”
-->在弹出的“安全验证”窗口,点击“前往验证”
-->使用手机扫描二维码,进行验证。待发送完短信验证后,点击“我已发送”
-->在弹出的页面,记住生成的“授权码”,在备注授权码用途上,填写其用途后,点击“关闭页面”
-->在“安全设置”页面,可以看到“POP3/IMAP/SMTP/Exchange/CardDAV/CalDAV服务”已开启