How to send clean emails from your application?

When developing an application that sends email notifications, what are the recommendations for

  • will not be marked by your spam agent as a spammer. (Cover of any of :)
    • the best way to not flood your mail server
    • best mail server products if you want to customize your own
    • sending messages as if it were a specific user, but itโ€™s nevertheless clear from your application (to ensure that complaints, etc. are returned to you), without violating good electronic etiquette.
    • any other lessons learned.
  • will not be marked as spam by the recipient client. (Cover of any of :)
    • Configuring and using sender identifiers, domain keys, SPFs, reverse DNS, etc., to ensure that your emails are correctly identified.
    • best SMTP header methods to avoid spam when sending emails to users (for example, using Sender and From connectors)
    • any other lessons learned.

Additional requirement: this application will send one message to one recipient based on the event. Thus, methods for sending the same message to multiple recipients are not applied.

+4
source share
3 answers

the best way to not flood your mail server

there is not much you can do about this, other than checking with your administrator a mail server (if this is a hosting account / is not in your control). but if the requirement is one email to one recipient per event, this should not be too much of a problem. the things that usually clog up mail systems are emails with hundreds (or more) of recipients.

if you have events that are firing all the time, maybe consider consolidating them and sending an email that summarizes them periodically.

sending messages as if it were a specific user, but still clear from your application (to ensure that complaints, etc. are returned to you), without violating good mail etiquette

you can accomplish this using the โ€œReply-Toโ€ header, in which clients will use this address instead of the From address when creating an email message.

you should also set the "Return-Path" header of any email, as email is often filtered out without it.

ex.

From: me@me.com Return-Path: me@me.com Reply-To: auto@myapp.com 

setup and use of sender identifiers, domain keys, SPF, reverse dns, etc. to make sure that your letters are correctly identified

it all depends on how much you own your mail and DNS servers. spf / sender-id etc. - All DNS problems, so you need to have access to DNS.

in your example, this may be a problem. since you are setting up mail for a specific user, an SPF must be installed for this user (for example) installed in their DNS so that your mail server is the actual sender. you can imagine how randomly (if not completely impossible) this would happen with a number of users with different domain names.

as for reverse DNS, etc., it really depends. most internet service provider clients etc ... just check to set reverse DNS. (i.e. 1.2.3.4 allows host.here.domain.com, even if host.here.domain.com does not allow return to 1.2.3.4). this is due to the amount of shared hosting (where mail servers often report themselves as the client's domain name, rather than a real mail server).

There are several strict networks that require reverse DNS mapping, but this requires that you control the mail server if it does not match in the first place.

if you can be more specific, I can provide a little more advice, but as a rule, for people who need to send application mail and they donโ€™t have a lot of control over their environment, I would suggest the following:

  • make sure the return path is set
  • It's nice to add your application and information about abuses, as well as in the headers, that is: "X-Mailer" and "X-Abuse-To" (these are custom headers, for informational purposes only).
  • make sure that the reverse DNS server is set for the outgoing mail server DNS address.
+5
source

first quick correction of the previous

return-path: this is a header added using a system based on the sender of the incoming message

for spf to work with the return / envelope, the sender must be yourapp@yourdomain.com

and provide an spf entry for yourdomain.com {or if for each user spf} for yourapp@yourdomain.com allows you to send letters to the server on which the application is located / sent an email

this sender envelope is the address that will receive all bounces / errors

Now the sender identifier is completely different, it checks the sender-sender-sender and from: address {stored inside the message} when sending from: hisname yourapp@yourdomain.com reply to: his name hisaddres@hisdomain.com

it will not be a problem when sending from: his name hisaddres@hisdomain.com

it will be, and you should add Resent-From: its name is yourapp@yourdomain.com as it indicates ignoring from: to check the sender ID use it instead, since it was sent by you on its behalf.

0
source

now for the other bits that stand

ip mentioned your mail servers

a let your ip ptr point to a name that also resolves the same ip FQDNs

b you have a helo / ehlo server with any.domain.com, where domain.com matches the name domain in step A (not the same name for resons below}

c have helo / ehlo servername also allow your server ip

d add the following spf entry to this name helo / ehlo "v = spf1 a -all" {means that helo / ehlo with this name from ip this name only points to}

e add the following lines of the sender identifier to the name helo / ehlo {purely for completeness "spf2.0 / mfrom, pra -all" {i.e. no users @ this-domain}

f add the following spf to the FQDNS name and any other hostnames for your server "v = spf1 -all" {i.e. no machines will ever be helo / ehlo like that name, not users @ this-domain}

{, since the name fqdns can be determined by bots / infections, it is better not to allow this name to be used in helo / ehlo greetings directly, it is enough that it is from the same domain as the helo / ehlo identification to prove the validity of both}

0
source

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


All Articles