Внедряем email-аутентификацию DKIM в Postfix за 5 минут

Работал у нас почтовый сервер для рассылки корреспонденции клиентам. И все бы ничего, но стал люд жаловаться, что не доходят письма или  в спам попадают. И хотя spf был настроен, все говорило о том, что пора нам к нашему Postfix прикрутить DKIM. Как гласит цитата откуда-то с хабра:

DKIM-подпись — это цифровая подпись, которая добавляется к заголовкам письма сервером отправителя, по которой сервер получателя может удостовериться, что отправитель письма соответствует полю From в заголовках письма. Если сервер получателя проверяет эту подпись, то по результатам проверки сервер может принять решение о том, как поступать с письмом: принять, отправлять в папку «Спам», отправить на дополнительную проверку или вовсе отказаться от приёма. Подписи DKIM проверяют и используют сами все ведущие почтовые службы, включая Яндекс и Mail.ru.

Для начала установим необходимый софт командой

aptitude install opendkim opendkim-tools

После установки необходимо отредактировать файл /etc/opendkim.conf, добавив в него строки

Canonicalization relaxed/relaxed
SyslogSuccess yes
KeyTable file:/etc/opendkim/keytable
SigningTable file:/etc/opendkim/signingtable
SoftwareHeader yes
LogWhy yes
ExternalIgnoreList file:/etc/opendkim/trusted
InternalHosts file:/etc/opendkim/trusted

Теперь создадим рабочий каталог,а в нем новый приватный и открытый ключ. Открытый ключ мы потом пропишем на нашем DNS-сервере.

mkdir /etc/opendkim/
opendkim-genkey -s mail -d example.com

В каталоге /etc/opendkim у вас должно появиться 2 новых файла. mail.private – это наш приватный ключ, которым мы будем подписывать письма. А mail.txt содержит публичный ключ. Список имеющихся ключей укажем в файле /etc/opendkim/keytable в формате “название домен:селектор:/путь/до/ключа”. В нашем случае содержимое файла будет таким:

mail._domainkey.example.com example.com:mail:/etc/opendkim/keys/example.com/mail.private

Теперь объясним OpenDKIM почту каких доменов какими ключами подписывать в файле /etc/opendkim/signingtable в формате “домен название-ключа”.

example.com mail._domainkey.example.com

В файле /etc/opendkim/trusted необходимо прописать ваши доверенные узлы:

127.0.0.1
localhost
192.168.1.0/24

Зададим необходимые права, добавим пользователя postfix в группу opendkim. Это нужно чтобы postfix смог отправлять письма на подпись через сокет OpenDKIM. После чего перезапустим службу. Я рекомендую заглянуть в системный лог и убедиться, что нет ошибок при запуске службы.

chown opendkim /etc/opendkim -R
gpasswd -a postfix opendkim
service opendkim restart

Вторым этапом настроим postfix, чтобы он мог подписывать нашу почту. В main.cf необходимо добавить:

milter_default_action=accept
milter_protocol=2
smtpd_milters=unix:/var/run/opendkim/opendkim.sock
non_smtpd_milters=unix:/var/run/opendkim/opendkim.sock

Ну и опять рестарт/релоад

service postfix restart

Третьим и последним этапом мы настроим наш DNS сервер добавив в него TXT запись. Выведите содержимое файла mail.txt и используйте следующую пару ключ-значение для добавления новой записи в DNS.

Name: mail._domainkey.example.com.
Text: "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC5N3lnvvrYgPCRSoqn+awTpE+iGYcKBPpo8HHbcFfCIIV10Hwo4PhCoGZSaKVHOjDm4yefKXhQjM7iKzEPuBatE7O47hAx1CJpNuIdLxhILSbEmbMxJrJAG0HZVn8z6EAoOHZNaPHmK2h4UUrjOG8zA5BHfzJf7tGwI+K619fFUwIDAQAB"

Для применения изменений в DNS может пройти несколько часов. Проверить DKIM-подпись вы можете отправив пиьсмо через свой сервер на ящик [email protected] Ответное письмо вы получите в виде отчета. Например:

=========================================================
Summary of Results
==========================================================
SPF check: pass
DomainKeys check: neutral
DKIM check: pass
Sender-ID check: pass
SpamAssassin check: ham

Полезные ссылки:

103 комментария к “Внедряем email-аутентификацию DKIM в Postfix за 5 минут

  1. Have you ever considered about including a little bit more than just your articles?

    I mean, what you say is important and everything.
    But think of if you added some great pictures or video clips to give
    your posts more, “pop”! Your content is excellent but with pics and
    video clips, this website could certainly be one of the most beneficial in its niche.
    Awesome blog! 32hvAj4 cheap flights

  2. An impressive share! I’ve just forwarded this onto a coworker who has been conducting a little
    research on this. And he actually bought me lunch
    simply because I found it for him… lol. So allow me to reword this….
    Thank YOU for the meal!! But yeah, thanks for spending some time to talk about this
    topic here on your web page.

  3. Please let me know if you’re looking for a author for your weblog.
    You have some really great posts and I feel I would be a good asset.
    If you ever want to take some of the load off, I’d absolutely love to write some articles for your blog in exchange for
    a link back to mine. Please blast me an email if interested.
    Many thanks!

  4. I am not sure where you are getting your information, but great topic.
    I needs to spend some time learning more or understanding more.
    Thanks for excellent information I was looking for this info for my mission.

  5. I am extremely impressed with your writing skills as well as with
    the layout on your blog. Is this a paid theme or did you customize it yourself?
    Either way keep up the nice quality writing,
    it’s rare to see a nice blog like this one these days.

  6. Please let me know if you’re looking for a writer for your weblog.
    You have some really good articles and I believe I would be
    a good asset. If you ever want to take some of the load off, I’d love to write some articles for your blog in exchange
    for a link back to mine. Please send me an e-mail if interested.
    Thank you!

  7. I like the valuable info you provide in your articles.

    I’ll bookmark your weblog and check again here regularly.
    I’m quite certain I’ll learn lots of new stuff right here!

    Best of luck for the next!

  8. Hey! I could have sworn I’ve been to this website before but after
    browsing through some of the post I realized it’s
    new to me. Nonetheless, I’m definitely happy I
    found it and I’ll be bookmarking and checking back often!

  9. When someone writes an paragraph he/she maintains the idea of a user in his/her brain that how
    a user can know it. So that’s why this piece of writing is outstdanding.
    Thanks!

  10. After going over a handful of the blog articles on your
    website, I truly appreciate your technique of writing a blog.
    I bookmarked it to my bookmark website list and will be checking back in the near future.
    Please visit my web site too and let me know
    what you think.

  11. I’m really enjoying the design and layout of your site.
    It’s a very easy on the eyes which makes it much more enjoyable for me to come here and
    visit more often. Did you hire out a designer to create your theme?

    Excellent work!

  12. I believe that is among the such a lot significant information for me.
    And i am happy reading your article. However should observation on few normal things, The
    site style is great, the articles is in point of fact nice :
    D. Good activity, cheers

  13. Nice blog right here! Additionally your web site so
    much up very fast! What web host are you using?
    Can I get your associate hyperlink in your host? I want my web site loaded up as fast as yours lol

  14. Normally I don’t learn post on blogs, however I
    wish to say that this write-up very forced me to try and
    do it! Your writing style has been surprised me.
    Thanks, quite great post.

  15. Having read this I believed it was rather enlightening.
    I appreciate you finding the time and effort to put this short article together.
    I once again find myself spending a significant amount of time both
    reading and commenting. But so what, it was still worthwhile!

  16. Hey There. I found your blog using msn. This is an extremely well
    written article. I will make sure to bookmark it and return to read more of your useful
    information. Thanks for the post. I’ll definitely return.

  17. Interesting blog! Is your theme custom made or did you download it from somewhere?
    A design like yours with a few simple adjustements would really make my blog shine.
    Please let me know where you got your design. Cheers

  18. Greetings, I believe your blog may be having internet browser compatibility problems.
    Whenever I look at your website in Safari, it looks fine however when opening
    in Internet Explorer, it’s got some overlapping
    issues. I just wanted to give you a quick heads up!
    Aside from that, fantastic blog!

  19. I got this web page from my friend who informed me regarding this web site and
    at the moment this time I am browsing this site and reading very informative posts at this place.

  20. What’s Happening i’m new to this, I stumbled upon this I have discovered It absolutely useful and it has helped me out
    loads. I am hoping to contribute & help other customers like
    its aided me. Good job.

  21. I have been surfing online more than 3 hours today, yet I never found any interesting article like yours.
    It’s pretty worth enough for me. Personally, if all site owners
    and bloggers made good content as you did, the net will be much more useful than ever
    before.

  22. Have you ever considered publishing an e-book
    or guest authoring on other sites? I have a blog based upon on the same information you discuss and would really like to have you share some
    stories/information. I know my visitors would value your work.
    If you’re even remotely interested, feel free to shoot me an e-mail.

  23. Oh my goodness! Incredible article dude! Thank you, However I am encountering problems with your RSS.
    I don’t understand why I can’t join it. Is there anyone
    else having the same RSS issues? Anyone who knows the answer can you kindly respond?
    Thanks!!

  24. Hello! I could have sworn I’ve visited this web site before but after going through many of the posts I realized it’s new to me.
    Anyways, I’m certainly pleased I found it and I’ll be bookmarking it and
    checking back often!

  25. Hello just wanted to give you a brief heads up and let you know a
    few of the images aren’t loading correctly.

    I’m not sure why but I think its a linking issue. I’ve tried it in two different web browsers and both show the same outcome.

  26. Attractive section of content. I just stumbled upon your
    web site and in accession capital to assert that I acquire actually enjoyed account your blog posts.
    Anyway I’ll be subscribing to your augment and even I achievement you access consistently fast.

  27. Pretty nice post. I just stumbled upon your weblog and wished to say that I
    have really enjoyed surfing around your blog posts.
    In any case I will be subscribing to your rss feed and I hope you write again very soon!

  28. First off I would like to say great blog! I had a
    quick question that I’d like to ask if you do not mind.
    I was interested to find out how you center yourself and clear your mind before writing.
    I have had a difficult time clearing my mind in getting my thoughts
    out. I truly do enjoy writing but it just seems like the first 10 to 15 minutes are generally wasted just trying
    to figure out how to begin. Any ideas or hints? Cheers!

  29. Thanks on your marvelous posting! I actually enjoyed reading it,
    you are a great author. I will make certain to bookmark your
    blog and will often come back later in life. I want to encourage one to continue
    your great writing, have a nice holiday weekend!

  30. I think this is among the most vital info for me.
    And i am glad reading your article. But should
    remark on few general things, The website style
    is great, the articles is really nice : D. Good job, cheers

  31. Greetings from Ohio! I’m bored to tears at work so I
    decided to check out your site on my iphone during lunch break.
    I love the information you present here and can’t wait to take a
    look when I get home. I’m amazed at how quick your blog loaded on my cell phone ..
    I’m not even using WIFI, just 3G .. Anyhow, very good blog!

  32. Hi, I do think this is an excellent web site. I stumbledupon it 😉 I
    will return yet again since I book marked it.
    Money and freedom is the greatest way to change, may you be
    rich and continue to help others.

  33. Thanks for some other wonderful post. The place else may just anyone get that type of information in such an ideal means of writing?
    I have a presentation subsequent week, and I am on the search for
    such info.

  34. Does your site have a contact page? I’m having a tough time locating it but,
    I’d like to shoot you an e-mail. I’ve got some ideas
    for your blog you might be interested in hearing. Either way, great website and I
    look forward to seeing it improve over time.

  35. Very great post. I simply stumbled upon your weblog and wanted to say that I’ve truly enjoyed browsing your weblog posts.
    After all I’ll be subscribing in your feed and I hope you write again very soon!

  36. I do not even know how I stopped up right here, however I believed this submit was once good.
    I do not know who you might be but certainly you are going to a well-known blogger in the event you aren’t already.
    Cheers!

  37. Great weblog here! Additionally your web site loads up very fast!
    What host are you using? Can I get your affiliate hyperlink for your host?
    I want my site loaded up as quickly as yours lol

  38. Woah! I’m really digging the template/theme of this site.

    It’s simple, yet effective. A lot of times it’s challenging
    to get that “perfect balance” between user friendliness and appearance.
    I must say you’ve done a awesome job with this. Additionally,
    the blog loads extremely quick for me on Chrome.
    Exceptional Blog!

  39. I know this if off topic but I’m looking into starting my own weblog and was
    curious what all is required to get set up? I’m assuming having a blog like yours
    would cost a pretty penny? I’m not very internet smart
    so I’m not 100% positive. Any tips or advice would be greatly appreciated.
    Thanks

  40. An impressive share! I have just forwarded this onto a friend who had
    been conducting a little research on this. And he actually ordered me lunch 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 discuss this matter
    here on your site.

  41. After I initially commented I appear to have clicked on the -Notify me when new comments are added- checkbox and from now on each time a comment
    is added I recieve four emails with the same comment.

    Is there a way you can remove me from that service? Cheers!

  42. I seriously love your site.. Great colors & theme. Did you make this site yourself?
    Please reply back as I’m wanting to create my own personal site and want to know where you got this from or exactly what the theme is
    called. Thanks!

  43. Thanks for every other fantastic post. Where else could anyone get that kind
    of info in such a perfect way of writing? I have a presentation next week, and I’m at the search
    for such information.

  44. I have been exploring for a little for any high quality articles or weblog posts in this
    sort of space . Exploring in Yahoo I eventually stumbled upon this web
    site. Studying this info So i’m happy to exhibit that I’ve a very excellent uncanny feeling I discovered just what I needed.

    I most indubitably will make certain to do not fail to remember this site and give it a glance regularly.

  45. Thanks for a marvelous posting! I definitely enjoyed reading it, you will be a great author.I will ensure that I bookmark your blog and may come back later on.
    I want to encourage you to continue your great posts, have a nice evening!

  46. I’m amazed, I must say. Rarely do I encounter a blog that’s both equally educative and amusing, and let me tell you, you’ve
    hit the nail on the head. The issue is something which too few people
    are speaking intelligently about. I’m very happy that
    I found this in my hunt for something concerning this.

  47. I like the valuable info you supply to your articles.
    I will bookmark your weblog and check again right
    here regularly. I’m moderately sure I will be informed many new stuff proper right here!
    Best of luck for the next!

  48. Greetings! Quick question that’s totally off topic. Do you know how
    to make your site mobile friendly? My site looks weird when viewing from my
    iphone 4. I’m trying to find a theme or plugin that might be able to fix this issue.
    If you have any suggestions, please share. Many thanks!

  49. I’m extremely impressed with your writing skills and
    also with the layout on your weblog. Is this a paid theme or did you modify it yourself?
    Either way keep up the nice quality writing, it’s
    rare to see a great blog like this one nowadays.

  50. It’s perfect time to make some plans for the longer term and it is time to
    be happy. I have read this post and if I could I desire to counsel you some fascinating issues or
    tips. Maybe you can write subsequent articles regarding this article.
    I desire to read even more things about it!

  51. Hello I am so thrilled I found your webpage, I really found you by error, while I was researching on Digg for something else, Nonetheless I am here now and would just like to say thanks a lot for a fantastic post and a all round entertaining blog (I also love
    the theme/design), I don’t have time to look over it all at the minute
    but I have book-marked it and also added
    in your RSS feeds, so when I have time I will be back to read a lot more, Please do
    keep up the fantastic jo.

  52. hello!,I really like your writing so much! proportion we keep in touch extra approximately your article on AOL?
    I require a specialist in this space to unravel my problem.
    May be that’s you! Looking forward to peer you.

  53. Hey I know this is off topic but I was wondering if you knew
    of any widgets I could add to my blog that automatically tweet my
    newest twitter updates. I’ve been looking for a plug-in like this for quite some time and
    was hoping maybe you would have some experience with something like this.
    Please let me know if you run into anything. I
    truly enjoy reading your blog and I look forward to your
    new updates.

  54. This is very attention-grabbing, You’re an overly professional blogger.
    I have joined your rss feed and look forward to looking for extra of your excellent post.
    Also, I’ve shared your website in my social networks

  55. Greetings! This is my first visit to your blog! We
    are a group of volunteers and starting a new initiative in a community in the same niche.
    Your blog provided us valuable information to work on. You have done a marvellous job!

  56. Hi there I am so excited I found your site, I really found
    you by mistake, while I was looking on Google for something else, Anyhow I am here now and would just
    like to say thank you for a tremendous post and a all round thrilling blog (I also love the theme/design), I don’t
    have time to browse it all at the minute but I have book-marked
    it and also added in your RSS feeds, so when I have time I will
    be back to read a great deal more, Please do keep up the fantastic
    work.

  57. This is really interesting, You’re a very skilled blogger.
    I’ve joined your feed and look forward to seeking more of your fantastic
    post. Also, I have shared your website in my social networks!

  58. You can definitely see your expertise within the work
    you write. The arena hopes for even more passionate writers
    such as you who aren’t afraid to mention how they believe. Always follow your heart.

  59. An interesting discussion is definitely worth comment.

    I do believe that you should publish more about this subject matter,
    it might not be a taboo subject but typically people do not speak about these issues.
    To the next! Cheers!!

  60. Hi! This is my 1st comment here so I just wanted to give a quick shout out and say I really enjoy reading through your articles. Can you suggest any other blogs/websites/forums that deal with the same topics? Thanks!|

Оставить ответ

Ваш адрес email не будет опубликован. Обязательные поля помечены *