chasquid 是golang 写的一个简单的smtp服务器
记录操作步骤:
; Assign “mail.example.com” to the server’s IP addresses.
; Replace these with the ones for your server.
mail A 198.51.100.7
mail AAAA 2001:db8::7
; The mail server for example.com is mail.example.com.
@ MX 10 mail
; Use SPF to say that the servers in “MX” above are allowed to send email
; for this domain, and nobody else.
@ TXT “v=spf1 mx -all”
sudo apt install chasquid
chasquid-util user-add [email protected]
创建mail.example.com的SSL证书。然后放到:
/etc/chasquid/certs/mail.example.com下面,命名按下面改一下。
The configuration is in /etc/chasquid/ by default, and has the following structure:
chasquid.conf Main config file.
domains/ Domains’ data.
certs/ Certificates to use, one dir per pair.
chasquid-util print-config
smtp-check example.com
注意主机防火墙要打开:465 587端口。
package main
import (
"fmt"
"net/smtp"
)
func main() {
addr := "mail.xx.com:587"
auth := smtp.PlainAuth("", "[email protected]", "xx", "mail.xx.com")
from := "[email protected]"
to := []string{"[email protected]"}
msg := []byte("To: [email protected]\r\n" +
"Subject: test!\r\n" +
"\r\n" +
"This is the email body.\r\n")
err := smtp.SendMail(addr, auth, from, to, msg)
fmt.Println(err)
}
推荐国民远程控制软件KKVIEW: https://www.kkview.com
一键控制公司/家电脑/手机.
则[email protected] 收到的邮件会转发到这个邮箱。
/etc/chasquid/domain/example.com/aliases 里面加入转发:
user: [email protected]
如果需要imap pop3,需要配置这个了:
Configure dovecot
First, install dovecot, and let chasquid use it for authorizing users. That way, you will only use a single system for managing users (dovecot).
sudo apt install dovecot-imapd dovecot-pop3d dovecot-lmtpd
cat <<EOF | sudo tee /etc/dovecot/conf.d/11-chasquid.conf
### Allow chasquid to authorize users via dovecot.
service auth {
unix_listener auth-chasquid-userdb {
mode = 0660
user = chasquid
}
unix_listener auth-chasquid-client {
mode = 0660
user = chasquid
}
}
EOF
You will need to configure dovecot authentication depending on your needs. For example, if you want to use only system users, or virtual users. See the /etc/dovecot/conf.d/10-auth.conf file, and the dovecot documentation for more details.
域名反向解析服务,TX云太坑收费。不搞 了。
启动错误, 如果出现users文件无法读取。请设置它的权限。
收信,出现no maildrop 错误,需要安装dovecot。
推荐国民远程控制软件KKVIEW,一键控制公司/家电脑/手机.