邮件服务器设置SSL

https://github.com/tomav/docker-mailserver/wiki/Configure-SSL#example-using-the-letsencrypt-certificates-on-a-synology-nas

https://github.com/certbot/certbot

https://letsencrypt.org/

https://certbot.eff.org/

https://github.com/diafygi/acme-tiny   一个简单的python角本,实现从letsencrypt.org下载TLS证书。比较实用

https://github.com/diafygi/acme-tiny

 

Configure SSL

There are multiple options to enable SSL:

  • using letsencrypt (recommended)
  • using self-signed certificates with the provided tool
  • using your own certificates

After installation, you can test your setup with checktls.com.

Let's encrypt (recommended)

To enable Let's Encrypt on your mail server, you have to:

  • get your certificate using letsencrypt client
  • add an environment variable SSL_TYPE with value letsencrypt (see docker-compose.yml.dist)
  • mount your whole letsencrypt folder to /etc/letsencrypt
  • the certs folder name located in letsencrypt/live/ must be the fqdn of your container responding to the hostname command. The full qualified domain name (fqdn) inside the docker container is build combining the hostname and domainname values of the docker-compose file, e. g.: hostname: mail; domainname: myserver.tld; fqdn: mail.myserver.tld

You don't have anything else to do. Enjoy.

Example using docker for letsencrypt

Make a directory to store your letsencrypt logs and configs.

In my case

mkdir -p /home/ubuntu/docker/letsencrypt/log 
mkdir -p /home/ubuntu/docker/letsencrypt/etc/letsencrypt
cd /home/ubuntu/docker/letsencrypt

Now get the certificate (modify mail.myserver.tld) and following the certbot instructions. This will need access to port 443 from the internet, adjust your firewall if needed

docker run --rm -ti -v $PWD/log/:/var/log/letsencrypt/ -v $PWD/etc/:/etc/letsencrypt/ -p 443:443 deliverous/certbot certonly --standalone -d mail.myserver.tld

You can now mount /home/ubuntu/docker/letsencrypt/etc/ in /etc/letsencrypt of docker-mailserver

To renew your certificate just run (this will need access to port 443 from the internet, adjust your firewall if needed)

docker run --rm -ti -v $PWD/log/:/var/log/letsencrypt/ -v $PWD/etc/:/etc/letsencrypt/ -p 443:443 deliverous/certbot renew

Example using docker, nginx-proxy and letsencrypt-nginx-proxy-companion

If you are running a web server already, it is non-trivial to generate a Let's Encrypt certificate for your mail server using certbot, because port 80 is already occupied. In the following example, we show how docker-mailserver can be run alongside the docker containers nginx-proxy and letsencrypt-nginx-proxy-companion.

There are several ways to start nginx-proxy and letsencrypt-nginx-proxy-companion. Any method should be suitable here. For example start nginx-proxy as in the letsencrypt-nginx-proxy-companion documentation:

docker run -d -p 80:80 -p 443:443 \
    --name nginx-proxy \
    -v /path/to/certs:/etc/nginx/certs:ro \
    -v /etc/nginx/vhost.d \
    -v /usr/share/nginx/html \
    -v /var/run/docker.sock:/tmp/docker.sock:ro \
    --label com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy \
    jwilder/nginx-proxy

Then start letsencrypt-nginx-proxy-companion:

docker run -d \
    -v /path/to/certs:/etc/nginx/certs:rw \
    -v /var/run/docker.sock:/var/run/docker.sock:ro \
    --volumes-from nginx-proxy \
    jrcs/letsencrypt-nginx-proxy-companion

Start the rest of your web server containers as usual.

Start another container for your mail.myserver.tld. This will generate a Let's Encrypt certificate for your domain, which can be used by docker-mailserver. It will also run a web server on port 80 at that address.:

docker run -d \
    --name webmail \
    -e "VIRTUAL_HOST=mail.myserver.tld" \
    -e "LETSENCRYPT_HOST=mail.myserver.tld" \
    -e "LETSENCRYPT_EMAIL=foo@bar.com" \
    library/nginx

You may want to add -e LETSENCRYPT_TEST=true to the above while testing to avoid the Let's Encrypt certificate generation rate limits.

Finally, start docker-mailserver with path/to/certs/mail.mydomain.tld mounted to /etc/letsencrypt/live/mail.mydomain.tld

Example using the letsencrypt certificates on a Synology NAS

Version 6.2 and later of the Synology NAS DSM OS now come with an interface to generate and renew letencrypt certificates. Navigation into your DSM control panel and go to Security, then click on the tab Certificate to generate and manage letsencrypt certificates. Amongst other things, you can use these to secure your mail server. DSM locates the generated certificates in a folder below /usr/syno/etc/certificate/_archive/. Navigate to that folder and note the 6 character random folder name of the certificate you'd like to use. Then, add the following to your docker-compose.yml declaration file:

volumes:
      - /usr/syno/etc/certificate/_archive/YOUR_FOLDER/:/tmp/ssl 
...
environment:
      - SSL_TYPE=manual
      - SSL_CERT_PATH=/tmp/ssl/fullchain.pem
      - SSL_KEY_PATH=/tmp/ssl/privkey.pem

DSM-generated letsencrypt certificates get auto-renewed every three months.

Self-signed certificates (testing only)

You can easily generate a self-signed SSL certificate by using the following command:

docker run -ti --rm -v "$(pwd)"/config/ssl:/ssl -h mail.my-domain.com -t tvial/docker-mailserver generate-ssl-certificate

# Press enter
# Enter a password when needed
# Fill information like Country, Organisation name
# Fill "my-domain.com" as FQDN for CA, and "mail.my-domain.com" for the certificate.
# They HAVE to be different, otherwise you'll get a `TXT_DB error number 2`
# Don't fill extras
# Enter same password when needed
# Sign the certificate? [y/n]:y
# 1 out of 1 certificate requests certified, commit? [y/n]y

# will generate:
# config/ssl/mail.my-domain.com-key.pem (used in postfix)
# config/ssl/mail.my-domain.com-req.pem (only used to generate other files)
# config/ssl/mail.my-domain.com-cert.pem (used in postfix)
# config/ssl/mail.my-domain.com-combined.pem (used in courier)
# config/ssl/demoCA/cacert.pem (certificate authority)

Note that the certificate will be generate for the container fqdn, that is passed as -h argument. Check the following page for more information regarding postfix and SSL/TLS configuration.

To use the certificate:

  • add SSL_TYPE=self-signed to your container environment variables
  • if a matching certificate (files listed above) is found in config/ssl, it will be automatically setup in postfix and dovecot. You just have to place them in config/ssl folder.

Custom certificate files

You can also provide your own certificate files. Add these entries to your docker-compose.yml:

volumes:
  - /etc/ssl:/tmp/ssl:ro
environment:
- SSL_TYPE=manual
- SSL_CERT_PATH=/tmp/ssl/cert/public.crt
- SSL_KEY_PATH=/tmp/ssl/private/private.key

This will mount the path where your ssl certificates reside as read-only under /tmp/ssl. Then all you have to do is to specify the location of your private key and the certificate.

Please note that you may have to restart your mailserver once the certificates change.

Testing certificate

From your host:

docker exec mail openssl s_client -connect 0.0.0.0:25 -starttls smtp -CApath /etc/ssl/certs/

or

docker exec mail openssl s_client -connect 0.0.0.0:143 -starttls imap -CApath /etc/ssl/certs/

And you should see the certificate chain, the server certificate and:

Verify return code: 0 (ok)

Plain text access

Not recommended for purposes other than testing.

Just add this to config/dovecot.cf:

ssl = yes
disable_plaintext_auth=no

These options in conjunction mean:

ssl=yes and disable_plaintext_auth=no: SSL/TLS is offered to the client, but the client is
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
C# 开发的邮件服务器 Features supports pop3 smtp imap etc. supports ssl/tls for pop3, smtp and imap. supports multi mail vitural server, can bind multi domains. supports run as windows service, winform application with or without tray icon control. supports remote management using mailservermanager.exe supports mail recycle bin supports plugins using api interfaces Build and release download source code or use the releases i provided. if from source code you should run afterbuild.bat after build the solution successfuly then you get the debug or release version from application folder. Installation run MailServerLauncher.exe to install as windows service or just run as desktop application with or without tray icon. Configuration run MailServerManager.exe at the machine runs mailserver service or app. Connect to server press connect button from menu. type server localhost or 127.0.0.1 or leave it empty type username Administrator with case sensitive type password emtpy press ok to connect with saving or not Add virtual server type name and select storage api [your vitural server]>system>general, add dns servers for query mailto's domain mx record. [your vitural server]>system>services, enable smtp and pop3 services and set ipaddress binding with or without ssl/tls. the host name is required when set bindings. eg. bind smtp service to smtp.[your.domain] + IPAddress.Any [your vitural server]>system>service>relay, 'send email using DNS' and set at least a local ipaddress binding for email sending. the name of the binding here only a name,not mean domain. [your vitural server]>system>logging, enable logging for all services when something error you can see the details from 'Logs and Events' node [your vitural server]>domains, set email host domain, eg. if your email will be [email protected] then the domain should be abc.domain, description is optional [your vitural server]>security, !!! important, add rules for your service to allow outside access like email client. eg. add a rule 'Smtp Allow All' for smtp service with ip allows between 0.0.0.0 to 255.255.255.255 to enable smtp service for outside access add 'Pop3 Allow All' and 'Rlay Allow All' like that too. [your vitural server]>filters, there are two types of filter named 'DnsBlackList' and 'VirusScan' its configurable by run it's executable from mail server install path. Domain name resolution Add smtp.[your.domain], pop3.[your.domain], imap.[your.domain] resolution to your server public ip address with A record or to your server domain with CNAME record. mx record is optional if [your.domain] has a A record.if not, you shoud add a mx record point to your server ip. Remote management to enable remote management you must add ACL to allow mail server managers connect from outside network. use MailServerAccessManager.exe to add management users or just use administrator. add rules to allow access from specific IPs or ip ranges The users here only for management cases.
MuseMailServer采用数据库作为基本数据的存储载体,支持多语言、远程管理、Webmail(AJAX PHP)、互联网邮件收发、(POP3,SMTP,IMAP,FTP)、数字水印/SSL加密、网络硬盘、邮件过滤、邮件监控、任务事件、反垃圾邮件邮件杀病毒、多域名邮件收发和邮件发送验证等功能,是公司,企事业单位和学校以及门户网站等的理想的邮件服务器软件。MuseMailServer以其设置简单,简捷易用,出色的稳定性和灵活的web邮件服务二次开发接口为用户的商务应用、办公应用、学习提供更好,更容易,更快捷的支持。 MuseMailServer从3.0版本开始,改变原有的基于文件型数据库的存储方式,采用易检索、高速度、数据备份、安全性和灵活性上更具效率的数据库。以适应日新月异的数字存储数据库化和海量数据存储的要求。和传统邮件服务器一样,MuseMailServer支持互联网邮件收发、网页邮件收发、邮件杀毒、智能邮件过滤、邮件监视、邮件备份、邮件转发、多域名邮件收发和邮件发送验证等功能。同时,由于内核基于数据库,MuseMailServer提供的内核和Webmail无论是速度效率还是安全性都有传统邮件服务器无法比拟的优势。开放式的COMAPI和数据库结构,支持存储过程和视图,这对大部分数据库维护人员和开发人员来说,他们可以对MuseMailServer自行定义和并在其之上进行集成和二次开发,使得MuseMailServer的灵活性在同类产品中更胜一筹。 在邮件系统最重要的人机交互界面—Webmail中,MuseMail应用先进的AJAX动态页面无刷新技术,采用当前最为流行的PHP语言,以插件和模块化多层设计模式实现,并且严格遵循W3C国际标准,以UTF-8的全球通用字符集为界面字符内码标准,使得系统在具备完美可操作性、人性化快捷处理界面的同时,能最大程度上满足不同语种和多语言字符Email同时存在的需求,最大程度上满足用户的各种需求。 邮件服务器软件中重要的一个部分就是邮件存储模块,该部分直接决定邮件服务器的性能和效率,MuseMailServer从3.0版本开始采用分开存储的方式,将邮件系统的用户信息和其他基本信息都存放到数据库中,而数据量比较大的信体数据采用文件方式进行存储.这样的设计方式大大提升了系统可支持的邮箱数量和性能,同时又缓解了数据库服务器的压力.对于服务器负载比较大和邮件数据比较多的情况,MuseMailServer还可以被部署成分布式模式,WEBMAIL和邮件存储以及内核都分别采用不同的服务器进行处理,这样将能成倍提升服务器性能和邮件系统的容量。 MuseMail Server邮件服务器软件 v5.2 更新内容: 1.在MIME组件中增加了获取附件编码类型的方法,修复了webmail中某些附件编码为qp时不能正常下载 的问题; 2.增加了地址簿信息,用户信息读取返回时的长度,修复了显示数据内容时乱码的问题; 3.修改了DNS缓存的自动清理模式,改为由MX记录属性值自动判断超时更新的方式,提升了邮件发送的 成功率; 4.webmail中个人配置中的发件人名称长度改成了最多可输入8个汉字; 5.完善了网络磁盘中的子目录的分页功能; 6.改善了webmail界面的操作友好性,如发邮件时信体中提到"附件"而没有加时会自动提示用户应该添 加附件; 7.修复了在webmail审核注册用户时因名字过长导致乱码的问题; 8.修复了个性签名乱码的问题; 9.增加了用户是否允许发送给外部(非本域)邮件的权限,让管理员能更灵活的对用户进行权限控制;
WinWebMail是安全高速的全功能邮件服务器,融合强大的功能与轻松的管理为一体,提供最佳的企业级邮件系统解决方案。 安全 · 支持 SMTP,SSL SMTP,POP3,SSL POP3,IMAP4,SSL IMAP4,LDAP,WebMail,CA Server,TLS/SSL,S/MIME,Daytime 服务。 · 支持数字证书服务并提供强大的管理功能,可直接在WebMail中撰写或阅读经过数字签名或数字加密的安全邮件(S/MIME)。为邮件服务器提供军事级别的高安全强度(4096位DH/DSS加密或2048位RSA加密)。 · 业内首创将聚类分析算法(Cluster Analysis)应用于邮件系统的垃圾邮件防治中,并因此获得卓越的反垃圾邮件效果。 · 提供高效的邮件杀毒功能,并支持多种杀毒引擎。 · 特有的问题回答投递机制,更配合强大的多层垃圾邮件防御体系和只有大型邮件服务器才有的仿人工垃圾邮件投诉分捡功能,让垃圾邮件彻底远离您的收件箱。 · 邮件服务器使用TLS/SSL标准安全套接字层通讯协议(1024位RSA加密),支持包括 SSL SMTP, SSL POP3, SSL IMAP4 安全通讯服务,防止网络侦听,使得通信更安全。 >>>更多... 强大 · 提供强大的网络硬盘功能,更可以分目录管理,并能为每一个网络存储的文件添加注释文档。 · 提供完善的文件夹共享功能,包括:私人以及存储文件夹的共享。 · 提供强大的讨论组(公共文件夹)功能,邮件系统可以创建高达9999个不同的讨论分区。 · 提供强大的四级地址簿及通讯组功能,包括:企业地址簿/私人地址簿/域公共地址簿/(系统)公共地址簿,并支持完善的管理机制。 · 提供强大的用户级虚拟邮箱功能,让用户的每一个私人文件夹都成为可以接收邮件的虚拟邮箱,并为每一个虚拟邮箱提供独立的自动转发以及自动回复功能。 >>>更多... 轻松 · 提供良好的Web支持,让您可以直接通过IE浏览器收、发电子邮件,更支持强大的Web远程管理服务,让您无需登录邮件服务器,仅靠IE浏览器就可以实现对邮件系统的全面管理。 · 支持邮件撤回功能,即使发错邮件也不用慌,轻松撤回邮件,让您再也不用为此后悔不已。 · 强大的日程管理功能可以帮助您轻松掌握每天的日程,通过日程共享以及邀请函功能更可以实现用户间的协同合作,有效提高工作效率。 · 提供完整的WebMail开发COM接口,以支持高级用户对WinWebMail邮件服务器进行的ASP程序二次开发。 >>>更多... 高速 · 在实际应用中:奔腾II 450 MHz 128M内存的独立邮件服务器上可以高性能地支持至少5000个邮箱。 初次安装后(已经安装好未注册版的请退出winwebmail ),把对应版本的注册机复制到安装目录(默认目录为:C:\WinWebMail),点击打开注册机,按提示关闭 现在WinWebMail 开始启动,然后点击电脑桌面右下角的图标 选择“注册”项,下图只是说明下我已经注册过了 在“用户数”选项里选择“无限用户”,在“序列号”里填写至少11个任意数字和字母,多填写不要紧 但不得少于11个,填好后点下面那个绿色的钩钩,此时出现注册机界面, 复制注册码,关闭注册机,出现“输入序列号错误”提示,点“确定退出注册界面 ”,再回到桌面右下角选择“注册”项,用户数一定要选择“无限用户数”(刚才复制的注册码是用于“无限用户数”的,其他用户数,比如2000的5000的要重复以上步骤进行注册。) 黏贴刚才复制的注册码,点绿色钩钩“无限用户数注册成功”。
要搭建一个邮件服务器,需要以下步骤: 1. 安装邮件服务器软件 常用的邮件服务器软件有Postfix、Sendmail、Exim等,这里以Postfix为例。 在Linux系统中,可以使用以下命令安装Postfix: ``` sudo apt-get install postfix ``` 2. 配置邮件服务器 在安装完成后,需要对Postfix进行配置。配置文件位于/etc/postfix/main.cf。 可以根据需要修改以下参数: - myhostname:设置邮件服务器的主机名 - mydomain:设置邮件服务器的域名 - mydestination:设置邮件服务器的目标地址 - relayhost:设置邮件服务器的中继主机 - smtpd_banner:设置SMTP服务器的欢迎信息 3. 安装邮件客户端软件 邮件客户端软件有很多种,常用的有Thunderbird、Outlook等。 在Linux系统中,可以使用以下命令安装Thunderbird: ``` sudo apt-get install thunderbird ``` 4. 测试邮件服务器 可以使用telnet命令测试邮件服务器是否正常工作。 例如,可以使用以下命令连接到邮件服务器: ``` telnet localhost 25 ``` 然后,可以输入以下命令测试邮件服务器: ``` EHLO example.com MAIL FROM:<[email protected]> RCPT TO:<[email protected]> DATA Subject: Test email This is a test email. . QUIT ``` 5. 配置DNS记录 为了让其他邮件服务器能够正确地发送邮件到你的邮件服务器,需要在DNS中添加MX记录。 例如,如果你的邮件服务器的域名为example.com,可以添加以下MX记录: ``` example.com. IN MX 10 mail.example.com. ``` 其中,10表示邮件服务器的优先级,mail.example.com表示邮件服务器的主机名。 6. 配置防火墙 为了保护邮件服务器的安全,需要在防火墙中开放SMTP和POP3端口。 例如,可以使用以下命令开放SMTP和POP3端口: ``` sudo ufw allow smtp sudo ufw allow pop3 ``` 7. 配置SSL证书 为了保护邮件服务器的安全,可以使用SSL证书对邮件服务器进行加密。 可以使用Let's Encrypt等免费的SSL证书服务,或者购买商业SSL证书。 在配置SSL证书后,需要在Postfix的配置文件中添加以下参数: ``` smtpd_tls_cert_file=/path/to/cert.pem smtpd_tls_key_file=/path/to/key.pem ``` 其中,/path/to/cert.pem和/path/to/key.pem分别表示SSL证书和私钥的路径。 8. 配置反垃圾邮件 为了防止垃圾邮件,可以使用反垃圾邮件软件,例如SpamAssassin。 在Linux系统中,可以使用以下命令安装SpamAssassin: ``` sudo apt-get install spamassassin ``` 然后,在Postfix的配置文件中添加以下参数: ``` smtpd_recipient_restrictions = permit_mynetworks, reject_unauth_destination, check_recipient_access hash:/etc/postfix/recipient_access, check_sender_access hash:/etc/postfix/sender_access, check_client_access hash:/etc/postfix/client_access, check_policy_service inet:127.0.0.1:10023 ``` 其中,check_policy_service inet:127.0.0.1:10023表示使用SpamAssassin进行反垃圾邮件检查。 9. 配置邮件备份 为了保护邮件数据的安全,可以使用邮件备份软件,例如Dovecot。 在Linux系统中,可以使用以下命令安装Dovecot: ``` sudo apt-get install dovecot-imapd dovecot-pop3d ``` 然后,在Dovecot的配置文件中添加以下参数: ``` mail_location = maildir:/var/mail/%u mail_privileged_group = mail ``` 其中,/var/mail/%u表示邮件存储的路径。 10. 配置邮件群发 为了方便邮件群发,可以使用邮件群发软件,例如Mailman。 在Linux系统中,可以使用以下命令安装Mailman: ``` sudo apt-get install mailman ``` 然后,在Mailman的配置文件中添加以下参数: ``` MTA = 'Postfix' ``` 其中,'Postfix'表示使用Postfix作为邮件服务器

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值