- 域名解析:
角色 | 记录类型 | 主机记录 | 记录值 |
---|---|---|---|
主域名 | A | @ | xx.xx.xx.xx |
邮件域名 | A | xx.xx.xx.xx | |
邮件服务器 | MX | @ | mail.xxxxx.com |
反垃圾配置 | TXT | @ | v=spf1 a mx ~al |
服务端:
- 卸载 sendmail:
yum -y remove sendmail
- 安装软件:
yum -y install postfix dovecot cyrus-sasl-* mailx
3 配置 postfix:vim /etc/postfix/main.cf
queue_directory = /var/spool/postfix command_directory = /usr/sbin daemon_directory = /usr/libexec/postfix data_directory = /var/lib/postfix mail_owner = postfix myhostname = mail.xxxxx.com #这里要换成你自己的邮箱服务器 mydomain = xxxxx.com #这里换成你自己的主机服务器 myorigin = $mydomain inet_interfaces = all inet_protocols = ipv4 mydestination = $myhostname, localhost.$mydomain, localhost,$mydomain,mail.$mydomain,www.$mydomain, ftp.$mydomain local_recipient_maps = unknown_local_recipient_reject_code = 550 mynetworks = 0.0.0.0/0 relay_domains = $mydestination alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases home_mailbox = Maildir/ smtpd_banner = $myhostname ESMTP debug_peer_level = 2 debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5 sendmail_path = /usr/sbin/sendmail.postfix newaliases_path = /usr/bin/newaliases.postfix mailq_path = /usr/bin/mailq.postfix setgid_group = postdrop html_directory = no manpage_directory = /usr/share/man sample_directory = /usr/share/doc/postfix-2.10.1/samples readme_directory = /usr/share/doc/postfix-2.10.1/README_FILES smtpd_sasl_auth_enable = yes smtpd_sasl_security_options = noanonymous broken_sasl_auth_clients = yes smtpd_recipient_restrictions = permit_sasl_authenticated,reject_unauth_destination,permit_mynetworks smtpd_client_restrictions = permit_sasl_authenticated
- 配置 dovecot:
- 配置监听协议:
vim /etc/dovecot/dovecot.conf
protocols = imap pop3 lmtp listen = * dict { } !include conf.d/*.conf !include_try local.conf
- 配置登录方式:
vim /etc/dovecot/conf.d/10-auth.conf
disable_plaintext_auth = no auth_mechanisms = plain login !include auth-system.conf.ext
- 配置邮件存储位置:
vim /etc/dovecot/conf.d/10-mail.conf
mail_location = maildir:~/Maildir namespace inbox { inbox = yes } first_valid_uid = 1000 mbox_write_locks = fcntl
- 配置 ssl(关闭):
vim /etc/dovecot/conf.d/10-ssl.conf
ssl = no ssl_cert = </etc/pki/dovecot/certs/dovecot.pem ssl_key = </etc/pki/dovecot/private/dovecot.pem
- 配置监听协议:
- 配置 sasl2:
- 配置系统认证:
vim /etc/sysconfig/saslauthd
SOCKETDIR=/run/saslauthd MECH=shadow FLAGS=
- 配置登录方式(创建新文件):
vim /usr/lib64/sasl2/smtpd.conf
pwcheck_method: saslauthd mech_list: PLAIN LOGIN log_level:3
- 配置系统认证:
- 添加用户:
useradd test_user passwd test_user
- 启动服务:
systemctl start dovecot systemctl start postfix systemctl start saslauthd
- 配置 mailx:
vim /etc/mail.rc
set append set ask set crt set dot set keep set emptybox set indentprefix="> " set quote set sendcharsets=iso-8859-1,utf-8 set showname set showto set newmail=nopoll set autocollapse set markanswered ignore received in-reply-to message-id references ignore mime-version content-transfer-encoding fwdretain subject date from to set bsdcompat set from=test_user@xxxxx.com set smtp=mail.xxxxx.com set smtp-auth-user=test_user set smtp-auth-password=test_pass set smtp-auth=login
- 发送邮件:
echo "内容" | mail -s "标题" test@gmail.com 或 mail -s "标题" test@gmail.com < test.txt
- 查看发送日志:
tail /var/log/maillog
- 卸载 sendmail:
客户端:
- 安装 telnet:
yum -y install telnet
- 登录( dovecot 的默认端口是110):
telnet xx.xx.xx.xx 110
- 命令介绍:
USER xxx:输入用户名 PASS xxx:输入密码 LIST:显示信箱 RETR n:打开第n封信
- 退出 telnet:
ctl+] quit
- 安装 telnet:
文档更新时间: 2024-04-19 15:11 作者:lee