📜 ⬆️ ⬇️

Email from your server: pitfalls

Recently, for several reasons, we decided to abandon the third-party service for email newsletters and send them from our server. I would like to point out a number of difficulties that we encountered in the process, and ways to solve them. This article almost doesn’t touch on the layout directly, but I didn’t find a more suitable hub.

Of course, if you have been in the subject for a long time, such tips may seem trivial and obvious, but a certain set of tricks and tips will be useful for novice mailers.


Answering machine


Be prepared for the fact that people do not understand why an answering machine is needed. Hundreds of very important auto-answers will be sprinkled on you: “Thank you!”, “I received your letter, I will answer as soon as I can” (why should I?), Or even simply “adylopryd”. Are they forced to fill in the auto-answer field ?! And the majority of autoresponders have a box on mail.ru (I hardly refrain from commenting on this).
')
Considering that in our helpdesk we form tickets from the responses to the mailing lists, we don’t want to overwhelm the support with hundreds of useless tickets after each mailing.

How to deal with them? It would seem that we open the RFC , read that we need to parse the Auto-Submitted header : for its presence and the inequality of the word no , we get a profit. So? Nope The key word there is SHOULD . And if, for example, gmail, yandex and yahoo took this as a guide to action, then mail.ru (again you?) Is too proud to listen to someone's advice. Thank you at least for the X-AutoReply title . The rambler also goes there with its X-Autogenerated . It is terrible to imagine that even more irresponsible servers like i.ua were invented on this score (they are still being discussed), but so far no auto-responses have been received from them. Maybe they just do not have such a function at all?

Server name


Remember that in the postfix myhostname parameter the FQDN must be specified. And if you don’t have example.com standing there, but just an example, you may have problems with the delivery of the letter. Again, Gmail, Yandex, and even MailRu are slaughtered for it, but the very ill-fated i.ua (as well as ukr.net) just spins letters without commenting on it.

Greylisting


Another trick from ukr.net. On this subject, they have only such a silly FAQ. The bottom line is that if your server is not known to ukrnet, then it will not immediately deliver letters. To get on his white list, you must send the same letter after a certain period of time. Fortunately, postfix supports this option by default, so you just have to wait a few hours after the first letter.

Quarantine


We are once again pleased with i.ua. For some reason known only to him, he decided to put part of our letters in quarantine. To get them out of this quarantine, you must enter the code sent in the letter, or follow the link in the same letter. Then I gave up - to write a separate parser of service letters to satisfy the whims of paranoid-minded administrators was not part of my plans.

Layout


About the very layout of letters on Habré already had a bunch of articles, I’d hardly add something new to them. I will speak a little from a different position: what to do when there is already an imposed page on the site, and it should be sent by letter. We, for example, have a newsletter, which is partly composed of materials on the site. Do not overturn it specifically for the letter? And if there are almost 200 such pages? And they are periodically edited?

Therefore, I found for myself a library that allows you to make the correct email version from a ready-made “website” html, with inline styles, absolute paths to pictures, styles corrected for email clients, etc. It does not always work out perfectly for her, but when it is necessary to send letters, it is still necessary, and the deadline is yesterday, the library helps a lot.

The plans here still have to embed it in the site workflow, so that it automatically creates an email version when the content changes.

cancel subscription


About the heading List-Unsubscribe on the same Habré wrote back in 2010 . The main thing to remember here is that in the same Gmail, that the "Unsubscribe" button appears in the letter, it is necessary that Google consider you to be a bona fide sender. In practice, you need to properly configure DKIM, including the next item. Also, at a minimum, Google does not require that the title of the List-Unsubscribe be exactly mailto: link, it is enough to link to the site with the unsubscribe page.

DKIM: Body hash did not verify


I came across such a phrase in the letter headers when I noticed that GMail does not place the “Unsubscribe” button in the part of the letters sent. In fact, everything is simple here - the letter body was changed after signing, so the hashes do not match.

Find out the reason for this was not so easy. But having rummaged, I found out that, according to RFC2822, the length of the message body string should not exceed 998 characters. For some reason, postfix (as I understand it) puts the hyphenation after the letter is signed, so it is better to submit a letter with the correctly arranged hyphenation to the postfix.

That's all for now. Together we can supplement this post with useful tips from our practice. And at the end of a small survey:

Source: https://habr.com/ru/post/275047/


All Articles