sendmail邮件服务器

Centos搭建邮件服务器sendmail+dovecot

这里采用的是linux的现成方法,不利于再次开发,但是基本也够用
如果想再次开发,建议使用james(apache旗下java开源项目)或者其他产品

改IP

hostname thaad.xyz
echo "thaad.xyz" > /etc/hostname
echo "127.0.0.1 thaad.xyz" >> /etc/hosts

安装

  • centos下的mail目录为/var/spool/mail/
  • sendmail 官方的文档位置为/var/mail/,在centos下只是个快链
yum install -y sendmail dovecot
sed -i "s/Addr=127.0.0.1/Addr=0.0.0.0/" /etc/mail/sendmail.cf
echo "mail_location = mbox:~/mail:INBOX=/var/spool/mail/%u" >> /etc/dovecot/dovecot.conf
systemctl enable sendmail.service --now
systemctl enable dovecot.service --now
systemctl enable saslauthd.service --now

增加邮箱用户及权限

  • 增加用户thaad密码为000000,需要把用户邮箱权限改为600(为防止未授权用户信息泄露)
adduser thaad
echo 'thaad:000000' | chpasswd
chmod 600 /var/spool/mail/thaad

发送到外网

  1. 域名记录里必须添加mx记录(邮箱专用的)
  2. 必须打开smtp端口(腾讯云的25端口是要申请的)
  3. 外网邮箱也必须把服务器域名加白名单

https://www.freebsd.org/doc/handbook/sendmail.html

echo "To:qq.com RELAY" >> /etc/mail/access

低内存开启的方式

  1. SSL会占用大量CPU资源,禁用
  2. 一般默认明文是不安全的,所以把“禁止明文”关闭
  3. imap pop3 lmtp三选一,我建立邮箱就是为了哪里都能看到,所以选pop3
hostname thaad.xyz
echo "thaad.xyz" > /etc/hostname
echo "127.0.0.1 thaad.xyz" >> /etc/hosts
yum install -y sendmail dovecot
sed -i "s/Addr=127.0.0.1/Addr=0.0.0.0/" /etc/mail/sendmail.cf
echo "disable_plaintext_auth = no" >> /etc/dovecot/dovecot.conf
echo "mail_location = mbox:~/mail:INBOX=/var/spool/mail/%u" >> /etc/dovecot/dovecot.conf
echo "protocols = pop3" >> /etc/dovecot/dovecot.conf
echo "ssl = no" >> /etc/dovecot/dovecot.conf
echo "To:qq.com RELAY" >> /etc/mail/access
systemctl enable sendmail.service --now
systemctl enable dovecot.service --now
adduser thaad
echo 'thaad:000000' | chpasswd
chmod 600 /var/spool/mail/thaad

你可能感兴趣的:(#,Centos7,#,Centos8)