This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
hints:classic_linux_mail_flow [2021/03/02 07:46] admin [Run Procmail and SpamAssassin] |
hints:classic_linux_mail_flow [2021/04/03 07:41] (current) admin [Receive a message from the network] |
||
---|---|---|---|
Line 2: | Line 2: | ||
Mail received from the Internet flows through the system as described below. | Mail received from the Internet flows through the system as described below. | ||
+ | |||
+ | The below discussion is somewhat intricate. You don't need to know any of this to get the benefit of mail in the [[:Classic Linux]] environment. But if you are using a .forward file to forward mail to any off-site location (Gmail, Yahoo, etc.), this disussion will help you understand how and why some spam might get forwarded too. | ||
===== Receive a message from the network ===== | ===== Receive a message from the network ===== | ||
Line 10: | Line 12: | ||
Postfix then feeds the same message to Rspamd in real time, i.e., while the same SMTP transaction is in progress. | Postfix then feeds the same message to Rspamd in real time, i.e., while the same SMTP transaction is in progress. | ||
- | |||
- | Rspamd does a large number of spam checks, including checking the headers added by OpenDKIM, and checking for DMARC and SPF records in DNS. | ||
Rspamd feeds the same message to Clamd, which checks for viruses and returns a result to Rspamd. | Rspamd feeds the same message to Clamd, which checks for viruses and returns a result to Rspamd. | ||
- | Rspamd then returns its final findings to Postfix, which may ask Postfix to: | + | Rspamd does a large number of spam checks, including checking the headers added by OpenDKIM, and checking for DMARC and SPF records in DNS.((For more information about how DKIM, SPF, and DMARC records work, see [[hints: |
+ | |||
+ | Rspamd then returns its final findings to Postfix. These findings | ||
- | * Accept the message as contains no spam and no virus. | ||
* Reject the message because it contains a virus. | * Reject the message because it contains a virus. | ||
- | * Reject the message because it contains spam with high certainty. | + | * Reject the message because it contains |
- | * Greylist the message, because it appears to be spam but not with high certainty. | + | * Greylist the message because it contains likely |
+ | * Accept the message because it contains no spam and no virus. | ||
- | Postfix acts on these findings. It will accept the message from the remote SMTP client, or it will send a permanent rejection reply to the remote SMTP client, or it will do greylisting by sending a temporary rejection to the remote SMTP client (which means try again later).((Most infected Microsoft Windows machines that are part of a botnet being used to send spam will not retry sending the same spam message, so greylisting eliminates almost all spam sent by such machines. The next time the same client sends a message from the same sender to the same recipient, within a predetermined period, it will not be greylisted.)) | + | Postfix acts on these findings. It will send a permanent rejection reply to the remote SMTP client |
If Postfix accepts the message, it expands aliases and domain names until it determines the final recipient, which in Classic Linux is always a Linux user. Let's call that user the first user, also called USER. | If Postfix accepts the message, it expands aliases and domain names until it determines the final recipient, which in Classic Linux is always a Linux user. Let's call that user the first user, also called USER. | ||
Line 30: | Line 32: | ||
Postfix checks to see if the first user USER has a .forward file in their home directory. If the message was addressed using [[:plus addressing]], | Postfix checks to see if the first user USER has a .forward file in their home directory. If the message was addressed using [[:plus addressing]], | ||
- | Postfix will follow instructions in first such file that was found,if any. So the message might be forwarded to some other address, or fed to a program, or some combination of these. | + | Postfix will follow instructions in first such file that was found, if any; and if so, the message might be forwarded to some other address, or fed to a program, or some combination of these. |
===== Run Procmail and SpamAssassin ===== | ===== Run Procmail and SpamAssassin ===== | ||
Line 42: | Line 44: | ||
Taking into account these preferences, | Taking into account these preferences, | ||
- | Because spam-checking is done in sequence by Rspamd and SpamAssassin, | + | Because spam-checking is done in sequence by Rspamd and SpamAssassin, |
If the first user has a .forward file that sends mail elsewhere, Procmail is not run, and therefore SpamAssassin is not run. | If the first user has a .forward file that sends mail elsewhere, Procmail is not run, and therefore SpamAssassin is not run. | ||
Line 48: | Line 50: | ||
If the first user's .forward file causes mail to go to a second user, then Postfix goes back to the step **check for .forward file** above, and looks for the second user's .forward file, if any. If the second user doesn' | If the first user's .forward file causes mail to go to a second user, then Postfix goes back to the step **check for .forward file** above, and looks for the second user's .forward file, if any. If the second user doesn' | ||
- | If the first user's .forward file causes mail to go off-site (i.e., mail is forwarded to some other place like Gmail, Yahoo, etc.), then SpamAssassin will never run for the first user. However, Rspamd already ran, so anything recognized as spam with high certainty | + | If the first user's .forward file causes mail to go off-site (i.e., mail is forwarded to some other place like Gmail, Yahoo, etc.), then SpamAssassin will never run for the first user. However, Rspamd already ran, so guaranteed spam — |
===== Spam thresholds ===== | ===== Spam thresholds ===== | ||
- | The threshold for rejecting spam based on Rspamd' | + | The threshold for rejecting spam based on Rspamd' |
+ | |||
+ | So to summarize, the combination of Rspamd and SpamAssassin will catch almost all spam, the guaranteed spam being rejected | ||
+ | |||
+ | Because of Rspamd' | ||
- | Because of Rspamd' | + | You can make the amount of forwarded |