使用Docker部署mailcow,自建邮局服务(一)

先决条件

  • 一台VPS,有独立IP,最低配置1C2G,建议2C4G以上,支持发件服务(未屏蔽邮件端口, 请咨询你的服务商),支持PTR反向解析(咨询你的服务商)
  • 操作系统:CentOS、Debian、Ubuntu均可
  • 安装了Docker和docker-composer
  • 一个域名,注册时间越长越好,建议使用主流后缀,如:.com/.net/.org

部分CentOS 7系统可能内置了postfix服务,会和mailcow端口冲突,可以先尝试执行下面的命令卸载postfix

#CentOS卸载postfix
yum -y remove postfix

#Debian或者Ubuntu卸载postfix
apt-get remove postfix

设置Linux主机名

假设您的顶级域名为domain.com,那么您的主机名需要设置为mail.domain.commx.domain.com,前缀自己取,反正是需要二级域名。

设置主机名的命令为:

hostnamectl set-hostname mail.domain.com

然后修改/etc/hosts,添加一行hosts解析,就是将mail.domain.com指向到您当前服务器的公网IP,命令如下:

echo '173.0.xx.xxx    mail.domain.com' >> /etc/hosts

部署mailcow

先克隆mailcow代码和脚本:

#CentOS安装Git
yum -y install git

#Debian安装Git
apt-get install git

#克隆mailcow代码
git clone https://github.com/mailcow/mailcow-dockerized

进入代码目录cd mailcow-dockerized执行初始化脚本:./generate_config.sh根据提示设置域名和时区等信息。注意:

  1. 域名要和上面设置的主机名一致,比如mail.domain.com
  2. 如果后续需要修改,可以编辑mailcow.conf这个配置文件

mailcow默认使用了80/443作为WEB端口,如果您的服务器上已经存在WEB服务,可能会导致端口冲突,我们可以修改mailcow.conf这个配置文件,将

HTTP_PORT=80
HTTPS_PORT=443

修改为其它端口,比如修改为:

HTTP_PORT=880
HTTPS_PORT=8443

然后执行下面的命令拉取容器镜像和启动:

#拉取镜像
docker-compose pull

#启动容器
docker-compose up -d

初始化mailcow和添加域名

安装成功后,访问您的IP + 端口进入WEB管理界面,默认用户名:admin,密码为:moohoo

进入后台后点右上方“配置 – 邮箱设置 – 添加域名”

注意:添加域名的时候这里需要填写您的顶级域名domian.com,比如您主机名设置的是mail.domain.com,那么这里添加域名的时候填写domain.com

添加邮箱解析

域名添加完毕后,右侧有个DNS按钮,点击这个按钮会对您的域名DNS进行检测和指引。

不过那个检测有点不准,而且并非所有记录都要添加,下面是必须添加的记录。

主机名记录类型记录值备注
mail.domain.comA您的IP填写你VPS的公网IP
您的IPPTRmail.domain.com可能需要联系服务商添加
domain.comMXmail.domain.com
autodiscover.domain.comCNAMEmail.domain.com
autoconfig.domain.comCNAMEmail.domain.com
domain.comTXTv=spf1 a mx ip4:173.0.xx.xxx ~allIP改成你自己的
dkim._domainkey.domain.comTXT从mailcow后台获取DKIM记录从mailcow后台获取

邮件测试

DNS解析添加完毕后,等待几分钟生效,然后在mailcow后台添加邮箱账号,并登录webmail进行发件测试。

打开 https://www.mail-tester.com/ 这个网站,然后用你的mailcow邮箱发送邮件,发送完毕后查看得分。

满分为10分,如果评分很差,mail-tester会给出提示,建议根据提示进行修正即可。

总结

上述步骤我们仅仅是完成了安装和初始化,其实后续还有很多配置和维护工作要做。比如禁用IPV6、反向代理、配置SSL证书、数据备份与恢复等,有兴趣的可以参考mailcow官方文档完成,后续xiaoz再分享mailcow配置方面的内容。

自建邮局比较复杂且步骤繁多,很多细节问题若处理不好很容易进垃圾箱。非必要情况建议使用第三方企业邮箱即可,除非有特殊需求。自建邮局虽然不受发件量限制,但不建议短时间内发送大量垃圾邮件,否则你的IP或域名很容易被拉黑,最后得不偿失。

mailcow官网:https://mailcow.email/

sanradar
sanradar
文章: 103

194 评论

  1. Hi there, just became alert to your blog through Google,
    and found that it is really informative. I am gonna watch out for brussels.
    I will be grateful if you continue this in future. Numerous people will
    be benefited from your writing. Cheers! Escape roomy lista

  2. Having read this I thought it was very enlightening. I appreciate you taking the time and energy to put this information together. I once again find myself personally spending a significant amount of time both reading and commenting. But so what, it was still worthwhile.

  3. Oh my goodness! Awesome article dude! Thanks, However I am going through troubles with your RSS. I don’t understand why I can’t subscribe to it. Is there anyone else getting similar RSS problems? Anyone that knows the answer will you kindly respond? Thanx.

  4. Spot on with this write-up, I honestly believe this site needs a great deal more attention. I’ll probably be back again to read through more, thanks for the advice!

  5. You ought to take part in a contest for one of the greatest blogs on the web. I most certainly will highly recommend this website!

  6. Oh my goodness! Awesome article dude! Thank you, However I am encountering troubles with your RSS. I don’t know why I can’t join it. Is there anyone else having identical RSS issues? Anyone that knows the solution can you kindly respond? Thanks!

  7. I must thank you for the efforts you have put in writing this website. I am hoping to see the same high-grade blog posts from you in the future as well. In truth, your creative writing abilities has inspired me to get my very own website now 😉

  8. Oh my goodness! Impressive article dude! Many thanks, However I am experiencing troubles with your RSS. I don’t understand the reason why I can’t subscribe to it. Is there anybody else having identical RSS issues? Anyone who knows the answer will you kindly respond? Thanks!!

  9. Good post. I learn something new and challenging on blogs I stumbleupon every day. It’s always exciting to read content from other writers and use something from other web sites.

  10. Greetings! Very useful advice within this post! It is the little changes which will make the most significant changes. Thanks for sharing!

  11. After I initially commented I seem to have clicked on the -Notify me when new comments are added- checkbox and now whenever a comment is added I receive 4 emails with the same comment. Is there an easy method you can remove me from that service? Many thanks.

  12. Hi, I do believe this is a great web site. I stumbledupon it 😉 I may return yet again since i have book marked it. Money and freedom is the best way to change, may you be rich and continue to help other people.

  13. You have made some good points there. I checked on the net for more information about the issue and found most individuals will go along with your views on this site.

  14. I like reading through an article that will make people think. Also, many thanks for allowing for me to comment.

  15. I have to thank you for the efforts you have put in penning this site. I’m hoping to view the same high-grade blog posts from you in the future as well. In truth, your creative writing abilities has encouraged me to get my own, personal blog now 😉

  16. The next time I read a blog, I hope that it doesn’t fail me just as much as this particular one. After all, Yes, it was my choice to read, nonetheless I really believed you would probably have something interesting to say. All I hear is a bunch of whining about something you could fix if you were not too busy seeking attention.

  17. Your style is unique in comparison to other people I’ve read stuff from. Thanks for posting when you’ve got the opportunity, Guess I’ll just bookmark this web site.

  18. Good site you’ve got here.. It’s difficult to find high quality writing like yours these days. I honestly appreciate people like you! Take care!!

  19. This is the perfect webpage for anyone who would like to understand this topic. You realize so much its almost hard to argue with you (not that I actually would want to…HaHa). You certainly put a new spin on a subject which has been discussed for decades. Great stuff, just great.

  20. Hello there! This blog post could not be written much better! Looking at this article reminds me of my previous roommate! He constantly kept preaching about this. I will forward this post to him. Fairly certain he will have a great read. Thanks for sharing!

  21. When I initially left a comment I appear to have clicked the -Notify me when new comments are added- checkbox and from now on whenever a comment is added I get 4 emails with the exact same comment. There has to be a way you can remove me from that service? Many thanks.

  22. Howdy! This blog post couldn’t be written much better! Going through this article reminds me of my previous roommate! He constantly kept talking about this. I most certainly will send this article to him. Fairly certain he’ll have a good read. I appreciate you for sharing!

  23. After going over a few of the blog articles on your web page, I really like your technique of writing a blog. I book-marked it to my bookmark webpage list and will be checking back in the near future. Please check out my web site too and let me know your opinion.

  24. Spot on with this write-up, I honestly believe that this website needs far more attention. I’ll probably be back again to read more, thanks for the information!

  25. An outstanding share! I’ve just forwarded this onto a colleague who had been conducting a little homework on this. And he in fact ordered me dinner simply because I discovered it for him… lol. So allow me to reword this…. Thanks for the meal!! But yeah, thanks for spending some time to discuss this matter here on your internet site.

  26. Aw, this was a really good post. Taking the time and actual effort to make a good article… but what can I say… I put things off a lot and don’t seem to get nearly anything done.

  27. Mysimba – Quick and Easy Weight Lass

    Mysimba is a medicine used along with diet and exercise to help manage weight in adults:

    who are obese (have a body-mass index – BMI – of 30 or more);
    who are overweight (have a BMI between 27 and 30) and have weight-related complications such as diabetes, abnormally high levels of fat in the blood, or high blood pressure.
    BMI is a measurement that indicates body weight relative to height.

    Mysimba contains the active substances naltrexone and bupropion.

    https://cutt.ly/RezL73vz

  28. Hi there! I could have sworn I’ve visited this site before but after going through some of the posts I realized it’s new to me. Anyways, I’m certainly pleased I came across it and I’ll be book-marking it and checking back regularly.

  29. I must thank you for the efforts you’ve put in penning this site. I’m hoping to check out the same high-grade blog posts by you later on as well. In truth, your creative writing abilities has encouraged me to get my own, personal website now 😉

  30. A motivating discussion is definitely worth comment. I do believe that you should write more on this issue, it might not be a taboo subject but typically people do not speak about such subjects. To the next! Many thanks!

  31. An impressive share! I have just forwarded this onto a colleague who had been doing a little homework on this. And he actually bought me dinner due to the fact that I discovered it for him… lol. So let me reword this…. Thanks for the meal!! But yeah, thanks for spending the time to talk about this issue here on your web site.

  32. The very next time I read a blog, I hope that it doesn’t fail me as much as this particular one. After all, Yes, it was my choice to read through, however I truly believed you would probably have something helpful to say. All I hear is a bunch of moaning about something that you could fix if you were not too busy seeking attention.

  33. After looking over a number of the blog posts on your website, I truly like your technique of blogging. I saved as a favorite it to my bookmark site list and will be checking back in the near future. Please check out my website too and let me know your opinion.

  34. You should be a part of a contest for one of the finest sites on the net. I most certainly will highly recommend this site!

  35. Nice post. I learn something totally new and challenging on blogs I stumbleupon on a daily basis. It will always be interesting to read articles from other writers and practice something from other websites.

  36. You’re so interesting! I don’t believe I have read through something like that before. So wonderful to find someone with some unique thoughts on this topic. Seriously.. thanks for starting this up. This site is something that is needed on the web, someone with a little originality.

  37. 3. Size – smart beta index is quite different from other type of indexes like equity index, it is applied to basically a chain of objectives as well as rule screens of every company’s index component.

  38. The next time I read a blog, Hopefully it doesn’t disappoint me just as much as this one. After all, I know it was my choice to read through, however I actually believed you would probably have something helpful to talk about. All I hear is a bunch of moaning about something you could fix if you weren’t too busy searching for attention.

  39. I would like to thank you for the efforts you’ve put in writing this blog. I am hoping to check out the same high-grade content from you later on as well. In truth, your creative writing abilities has inspired me to get my own, personal site now 😉

  40. I blog quite often and I truly appreciate your information. This article has really peaked my interest. I am going to book mark your website and keep checking for new information about once a week. I subscribed to your RSS feed as well.

  41. Aw, this was an exceptionally good post. Taking a few minutes and actual effort to make a good article… but what can I say… I procrastinate a whole lot and don’t seem to get nearly anything done.

  42. Tradenext software solutions deals with the Forex Market offering specialized Money Manager, IB and White Label services as well as many benefits including tight pip fixed spreads, leverage ranging from 1:100 to 1:200 to permit the use of scalping, hedging options and Expert Advisors or robot dealers.

  43. Hi there! This blog post couldn’t be written much better! Going through this article reminds me of my previous roommate! He constantly kept preaching about this. I’ll send this post to him. Pretty sure he will have a good read. I appreciate you for sharing!

  44. Aw, this was a very nice post. Spending some time and actual effort to generate a great article… but what can I say… I put things off a lot and don’t seem to get anything done.

  45. I’m very pleased to discover this great site. I want to to thank you for your time just for this fantastic read!! I definitely enjoyed every bit of it and i also have you book-marked to look at new information in your site.

  46. You need to take part in a contest for one of the highest quality websites on the net. I will recommend this website!

  47. Can I just say what a relief to discover someone who genuinely knows what they are discussing over the internet. You definitely know how to bring an issue to light and make it important. More and more people really need to look at this and understand this side of the story. It’s surprising you aren’t more popular because you definitely possess the gift.

  48. Industry teams have argued that increased economic performance in those sectors will solely strengthen requirements in collaborating nations, and that EU commerce agreements should go hand in hand with harmonisation efforts for environmental rules.

  49. Roberto Perotti showed that in accordance with the credit market imperfection approach, developed by Galor and Zeira, inequality is associated with lower level of human capital formation (education, experience, apprenticeship) and higher level of fertility, while lower level of human capital is associated with lower levels of economic growth.

  50. Профессиональный сервисный центр по ремонту сотовых телефонов, смартфонов и мобильных устройств.
    Мы предлагаем: ремонт смартфонов
    Наши мастера оперативно устранят неисправности вашего устройства в сервисе или с выездом на дом!

  51. I recently did a system restore on my computer and have yet to reload my antivirus software. Apparently somewhere along the process something called Antivi took over my computer and I can’t do anything, not even get to my task manager to end the program. Any advice?.

  52. The reasons are a combination of the tribulations of Houston mixed with the trials of New York – the already low-lying area is sinking due to overzealous groundwater extraction, mixed with the resettling of land once covered by an ancient sheet of ice.

  53. Their eleven notified creditors have themselves, the automatic keep un break place and with him to make contact with enemy not more till the meetings of the creditors, who will happen among 20 days and 40 days.

  54. But if the futures market does not go anywhere for a few months, then the customer is shocked to know that his capital has not been sustained, but has become seriously worsened.

  55. Hi there! This article couldn’t be written any better! Going through this article reminds me of my previous roommate! He always kept preaching about this. I most certainly will send this post to him. Fairly certain he’s going to have a great read. Thanks for sharing!

  56. Having read this I thought it was rather informative. I appreciate you taking the time and energy to put this content together. I once again find myself spending a significant amount of time both reading and commenting. But so what, it was still worthwhile.

  57. You are so awesome! I don’t suppose I’ve read through a single thing like this before. So wonderful to find another person with some original thoughts on this subject matter. Seriously.. many thanks for starting this up. This site is one thing that’s needed on the internet, someone with some originality.

  58. I want to to thank you for this great read!! I certainly loved every little bit of it. I’ve got you saved as a favorite to look at new things you post…

  59. Hello!
    Take your favorite casino games with you wherever you go! Get up to $1,000 bonus back on your first 24 hours play with betPARX! -https://tinyurl.com/3cxurpma

    Good luck 🙂

  60. Right here is the perfect webpage for anybody who really wants to understand this topic. You understand so much its almost tough to argue with you (not that I personally will need to…HaHa). You certainly put a fresh spin on a topic that’s been written about for ages. Great stuff, just great.

  61. After checking out a handful of the articles on your website, I really like your way of blogging. I saved it to my bookmark site list and will be checking back in the near future. Please check out my website too and tell me your opinion.

  62. Next time I read a blog, Hopefully it won’t fail me as much as this one. I mean, I know it was my choice to read, but I actually thought you would probably have something helpful to say. All I hear is a bunch of whining about something you could possibly fix if you weren’t too busy looking for attention.

  63. An impressive share! I’ve just forwarded this onto a colleague who was doing a little homework on this. And he actually bought me lunch simply because I discovered it for him… lol. So let me reword this…. Thank YOU for the meal!! But yeah, thanks for spending time to talk about this issue here on your internet site.

  64. For International Banking, it offers investment banking and financing merchandise for company and institutional purchasers, including corporate banking, funding banking, capital markets, trade services, payments and cash management, and leveraged acquisition finance.

  65. A research of a cross-section of Subchapter S firms with an Worker Inventory Possession Plan exhibits that S ESOP firms performed better in 2008 compared to non-S ESOP firms, paid their workers greater wages on common than different firms in the identical industries, contributed extra to their staff’ retirement safety, and hired workers when the overall U.S.

  66. I need to to thank you for this great read!! I certainly loved every little bit of it. I have you saved as a favorite to check out new stuff you post…

  67. Everything is very open with a precise description of the issues. It was truly informative. Your website is useful. Thank you for sharing.

  68. Hello there, I believe your website might be having internet browser compatibility issues. Whenever I look at your website in Safari, it looks fine however, when opening in Internet Explorer, it’s got some overlapping issues. I simply wanted to give you a quick heads up! Aside from that, wonderful blog.

  69. I would like to thank you for the efforts you have put in penning this site. I’m hoping to see the same high-grade blog posts from you in the future as well. In fact, your creative writing abilities has inspired me to get my own site now 😉

  70. After looking at a handful of the articles on your website, I truly appreciate your technique of blogging. I saved as a favorite it to my bookmark site list and will be checking back in the near future. Please check out my web site as well and let me know what you think.

  71. You are so cool! I don’t believe I’ve read anything like that before. So good to discover another person with genuine thoughts on this issue. Really.. thanks for starting this up. This web site is something that’s needed on the internet, someone with a little originality.

留下评论

您的电子邮箱地址不会被公开。 必填项已用 * 标注