====== Postfix 邮箱服务 ====== 价格很不错的企业邮箱 [[https://www.zoho.com/mail/|Zoho Mail]] [[http://zoho.com.cn|中文版]](([[https://www.daniao.org/4053.html|Zoho Mail企业(域名)邮箱免费版申请与使用教程]])) 选择二:[[https://www.hostinger.com.hk/email-hosting|Hostringer 邮件服务]] [[https://www.mail-tester.com/|邮件评分测试]] ====== SPF 记录 ====== 为避免通过 cloudflare 路由的邮件被认为是垃圾邮件,需要增加一条txt记录。记录名称填自己的域名 v=spf1 include:_spf.mx.cloudflare.net ~all (邮件评分测试网站可以给出建议) ====== Postfix ====== 在树莓pi上安装webmin是个很不错的选项 [[https://www.webmin.com/deb.html|webmin 安装指南]] [[https://www.cisco.com/c/zh_cn/support/docs/smb/cloud-and-systems-management/network-automation-and-management/Installing_Postfix_Mail_Server_on_a_Raspberry_Pi.pdf|中文 pdf]] [[https://cloud.tencent.com/developer/article/1363216|在Debian 9上安装和配置Postfix作为仅发送SMTP服务器]] [[https://docs.oracle.com/zh-cn/learn/oracle-linux-postfix/index.html#introduction|Oracle Linux 上安装和配置 Postfix]] hostname 更改为 mail.simpinvest.gq * /etc/hostname -> pi * /etc/hosts => 127.0.0.1 mail.simpinvest.gq pi 修改 /etc/postfix/main.cf 文件 postconf -e 'xxx' 修改设置。关键的几个设置为: inet_interfaces = loopback-only 或者 all\\ mydestination = ''$myhostname'', ''localhost.$your_domain'', ''$your_domain''\\ ''%%sudo systemctl restart postfix%%'' 安装 mailutils 并使用 mail 命令测试 echo "This is the body of the email" | mail -s "This is the subject line" info@simpinvest.cf LOL 之前试过很多次发送到谷歌邮箱都不成功,以为postfix设置错了。今天偶尔发送了info@simpinvest.cf,发现成功递送到了。原因是在cloudflare上为siminvest.gq域名设置了邮件路由。看来问题出现在路由上。 MX记录: - 增加一个A记录"mail",地址指向服务器。仅限DNS - 增加一个MX记录,@ mail.simpinvest.gq [[https://www.renfei.org/blog/introduction-to-spf.html|SPF记录]] 允许从本服务器发出的邮件 * v=spf1 ip4:88.153.171.94 ~all 设置 ''masquerade_domains = $mydomain'' 让发件人前面省略掉 "mail." 字样。 [[https://www.loshub.com/topic/show/283/|Postfix配置DKIM签名]] - [[https://kb.linuxlove.xyz/mail-server-dkim.html|set up dkim on ubuntu]] 按照英文帖子修改。注意 Socket local:/var/spool/postfix/opendkim/opendkim.sock 以及 PidFile 也要保留。否则无法重启。 示例 |类型|名称 | 值 |TTL | | A | mail |128.199.254.32 | 1小时 | | MX | @ |mail.example.com(优先:10) | 1小时 | | TXT | @ |v=spf1 mx:mail.example.com ip4:128.199.254.32 ~all | 1小时 | | TXT | mail._domain |keyv=DKIM1;k=rsa; p=MIGfMA0GCSqGSI… | 1小时 | ===== 匿名发送邮件 ===== 需要在postfix添加客户服务器,例如mac的局域网内地址是 192.168.0.240,postfix 服务器地址是 192.168.0.159:\\ ''mynetworks = 127.0.0.0/8'' 192.168.0.240 ''[::ffff:127.0.0.0]/104 [::1]/128'' import Mailer from 'nodemailer' let transporter = Mailer.createTransport({ host: '192.168.0.159', port: 25, secure: false, // auth: { // user: 'tech', // pass: '123456' // }, tls:{ rejectUnauthorized: false } }) ===== 接收空用户邮件 ===== 编辑 /etc/postfix/main.cf 文件,添加两行代码。所有寄给不存在用户的邮件都由tech代收。 // luser_relay = tech$mydomain 干脆直接转到外网 luser_relay = pi@simpinvest.cf // 表示全部从pi转过来的 local_recipient_maps = (然后再转发给谷歌邮箱就好了 "@simpinvest.gq goldentianya@gmail.com"。实验不work,只有明确给tech用户的会转发,其余只是由tech来接收) ===== 转发邮件 ===== 配置文件(/etc/postfix/main.cf)并添加下面的配置。更改simpinvest.gq和example.net域名为您的域名 (([[https://blog.csdn.net/Real_Myth/article/details/54667857|在Postfix中设置邮件转发]])) virtual_alias_domains = simpinvest.gq example.net virtual_alias_maps = hash:/etc/postfix/virtual 编辑 /etc/postfix/virtual 文件,添加转发规则 tech@simpinvest.gq tech_pi@simpinvest.cf // 转发到 root@simpinvest.gq root_pi@simpinvest.cf @simpinvest.gq info_pi@simpinvest.cf * 接收任何用户的信,并自动转发到Gmail进行管理 * 可以匿名以任何用户的名字发信 ===== 邮件认证 ===== * [[http://www.daliycode.com/info-3-201.html|ubuntu搭建postfix smtp邮箱服务为站点发送邮件]] * [[https://damiansheldon.github.io/blog/how-to-set-up-a-postfix-e-mail-server-with-dovecot.html|如何搭建一个带 Dovecot 的 Postfix 邮件服务器]] ====== PostfixAdmin ====== * [[https://www.myfreax.com/set-up-an-email-server-with-postfixadmin/|使用PostfixAdmin设置邮件服务器]] * [[https://postfixadmin.sourceforge.io/|postfixadmin]] * [[https://www.linuxbabe.com/mail-server/host-multiple-mail-domains-in-postfixadmin|How to Host Multiple Mail Domains in PostfixAdmin on Ubuntu]]