系统:centos7.9
软件:exim、mailx
Version: exim-4.94.2、mailx-12.5
安装:yum install exim mailx -y(需安装epel-release)
/etc/exim4/exim4.conf #配置文件
/etc/hosts
/var/log/exim/main.log #日志文件
alternatives --set mta /usr/sbin/sendmail.exim
vi /etc/exim/exim.conf
primary_hostname = server.net #系统邮件名称,未指定将使用主机名
domainlist local_domains = @ #标识要在本地主机上传递的域,@为本地主机名称
domainlist relay_to_domains = #邮件中继,默认不允许
hostlist relay_from_hosts = 127.0.0.1 #允许从主机或IP 地址进行中继,默认只允许本机
# tls_advertise_hosts = * #设置tls证书
# tls_certificate = /etc/ssl/exim.crt
# tls_privatekey = /etc/ssl/exim.pem
daemon_smtp_ports = 25 #设置端口号
# tls_on_connect_ports = 465 #设置tls端口号
vi /etc/hosts
127.0.0.1 server.net #添加主机名与IP地址映射,否则提示发件人地址错误
systemctl start exim
防火墙开放端口号25
修改主机名
hostnamectl set-hostname server.net
指定发件人发送邮件
echo “aaa” | mail -r no-reply@server.net -s “exim test” 12345@qq.com
不指定发件人默认使用当前用户
echo “aaa” | mail -s “exim test” 12345@qq.com