当前位置: 首页 > article >正文

linux 下mailx 的使用。发送短信

1. 安装 mailx 

yum install -y mailx

2.请求数字证书

163 邮箱

mkdir -p /root/.certs/                           ####创建目录,用来存放证书
echo -n | openssl s_client -connect smtp.163.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/.certs/163.crt                    ####向163请求证书
certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/163.crt                  ####添加一个SSL证书到证书数据库中
certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/163.crt               ####添加一个Global 证书到证书数据库中
certutil -L -d /root/.certs                         ####列出目录下证书

qq

mkdir -p /root/.certs/                           ####创建目录,用来存放证书
echo -n | openssl s_client -connect smtp.qq.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/.certs/qq.crt                    ####向163请求证书
certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/qq.crt                  ####添加一个SSL证书到证书数据库中
certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/qq.crt               ####添加一个Global 证书到证书数据库中
certutil -L -d /root/.certs                         ####列出目录下证书

3.修改配置文件

163

vim /etc/mail.rc

# 以下为文件中的内容

set bsdcompat
set from=xxx@163.com
set smtp=smtps://smtp.163.com:465
set smtp-auth-user=xxx@163.com
set smtp-auth-password=授权密码
set ssl-verify=ignore
set nss-config-dir=/root/.certs
set smtp-auth=login

qq

vim /etc/mail.rc

# 以下为文件中的内容

set bsdcompat
set from=xxx@qq.com
set smtp=smtps://smtp.qq.com:465
set smtp-auth-user=xxx@qq.com
set smtp-auth-password=授权密码
set ssl-verify=ignore
set nss-config-dir=/root/.certs
set smtp-auth=login

说明:

set from=user@xxx.com               # 设置发信人邮箱和昵称

set smtp=smtps://smtp.xxx.com:465   # 这里填入smtp地址

set smtp-auth-user=user@xxx.com     # 这里输入邮箱账号

set smtp-auth-password=password     # 这里填入授权密码

set ssl-verify=ignore               # 忽略证书警告

set nss-config-dir=/root/.certs   # 证书所在目录
set smtp-auth=login                 # 认证方式
#set smtp-use-starttls=yes          # STARTTLS时使用

多用户:

account wangyi  {
set bsdcompat
set from=xxx@163.com
set smtp=smtps://smtp.163.com:465
set smtp-auth-user=xxx@163.com
set smtp-auth-password=授权密码
set ssl-verify=ignore
set nss-config-dir=/root/.certs
set smtp-auth=login
}
account qq {
set bsdcompat
set from=xxx@qq.com
set smtp=smtps://smtp.qq.com:465
set smtp-auth-user=xxx@qq.com
set smtp-auth-password=授权密码
set ssl-verify=ignore
set nss-config-dir=/root/.certs
set smtp-auth=login
}

4. 证书不被信任

# 依次执行以下内容

cd /root/.certs/

ll

certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ./ -i 163.crt

如果提示:Notice: Trust flag u is set automatically if the private key is present.表示添加成功

5. 测试:

echo “test” | mail -s "主题"  邮箱地址

# 添加附件 附件为 hello.log 

echo “正文内容” | mail -a hello.log -A qq -s "主题"  xxx@qq.com

-a: 附件

-A: 账户 (配置在 mail 文件中,使用与多用户情况)

说明:

三种常用方式:

echo '邮件内容' | mail -s '邮件标题' 收件人邮箱

cat 邮件内容.txt | mail -s '邮件标题' 收件人邮箱

mail -s '邮件标题' 收件人邮箱 < 邮件内容.txt

6. 发送qq 邮箱报错:Error in certificate: Peer’s certificate issuer is not recognized

cd /root/.certs/
ll
certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ./ -i qq.crt

http://www.kler.cn/news/324835.html

相关文章:

  • 在vue项目中禁用鼠标右键,选中
  • STM32 MCU学习资源
  • excel怎么转换json
  • Linux中gcc,g++常用编译选项
  • composer环境变量(phpstudy集成环境)无法使用问题
  • 【iOS】MVC架构模式
  • Linux系统中命令wc
  • Python:Spoonfed - (2-09) Cinema 4D 选择 (搬砖)
  • macos搭建flutter开发环境 3.24.3版本 2024年9月25日实测部署
  • 【Python】Django Grappelli:打造优雅且现代化的 Django 管理后台
  • win10如何禁止指定程序运行?教你5个方法!抓紧学!码住了!
  • jetlinks物联网平台学习4:http协议设备接入
  • hive如何删除分区
  • Maven-三、聚合
  • 【Python】FeinCMS:轻量级且可扩展的Django内容管理系统
  • 应用性能管理工具-SkyWalking
  • 精通Maven:多模块项目中的依赖管理
  • 支付宝沙箱环境 支付
  • 18.Linux-配置DNF仓库
  • 15分钟学 Python 第29天 : 数据库基础
  • 【Linux】防火墙
  • 《马力欧+疯狂兔子 星耀之愿》风灵月影修改器秘籍:轻松征服星辰大海
  • 数据结构——顺序表(基础代码题)
  • 【chrome 插件】初窥
  • JAVA基础:AtomicInteger
  • 解锁高效工作的秘密武器
  • 足底筋膜炎怎么治疗才能彻底除根
  • 学习之什么是装饰器
  • 【django】django项目使用https访问+ssl证书
  • Java基于easyExcel的自定义表格格式