User Tools

Site Tools


computing:mailserver-trixie

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
computing:mailserver-trixie [2026/05/31 03:47] oemb1905computing:mailserver-trixie [2026/07/28 19:52] (current) oemb1905
Line 11: Line 11:
 ------------------------------------------- -------------------------------------------
  
-  * [[https://nextcloud.haacksnetworking.org/index.php/s/s6wAL5p7jKHc9Db|Slides]] +  * [[https://cloud.haacksnetworking.org/index.php/s/P255xsGX37We4BS|Slides]] 
-  * [[https://content.haacksnetworking.org/w/nsMwnJhLnfMrs17W5cAdWg|SeaGL Presentation]]+  * [[https://content.haacksnetworking.org/w/erLgeVDEdeUf84FXq2Xk4f|SeaGL Presentation]]
   * [[https://tech.haacksnetworking.org/2025/06/10/your-email-your-rules-self-hosting-simplified/|Blog Post]]   * [[https://tech.haacksnetworking.org/2025/06/10/your-email-your-rules-self-hosting-simplified/|Blog Post]]
  
Line 287: Line 287:
 </code> </code>
  
-Similarly, for large IMAP folders, you also want to adjust IMAP's logic to provide 256k (vs. 64k) to each single IMAP command. Additionally, make sure that you raise simultaneous connections from a single IP to 25, 50, or more, so your client can handle more in parallel. Lastly, adjust the idle time notification as well for less latency and snappier results. The default is 2mins, but if this is your server only, you can safely go as low as 15s or 30s. This lowering not only helps Roundcube, but helps Delta Chat and other email clients as well.+Similarly, for large IMAP folders, you also want to adjust IMAP's logic to provide 256k (vs. 64k) to each single IMAP command. Additionally, make sure that you raise simultaneous connections from a single IP to 25, 50, or more, so your client can handle more in parallel. Lastly, adjust the idle time notification as well for less latency and snappier results. The default is 2mins, but if this is your server only, you can safely go as low as 15s or 30s. This lowering not only helps Roundcube, but helps Delta Chat and other email clients as well. Open up ''/etc/dovecot/conf.d/20-imap.conf'' and add the following towards the bottom:
  
 <code> <code>
Line 334: Line 334:
 #spf incoming policy and recipient restrictions\ #spf incoming policy and recipient restrictions\
 policyd-spf_time_limit = 3600\ policyd-spf_time_limit = 3600\
-smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, check_policy_service unix:private/policyd-spf+smtpd_recipient_restrictions =  
 +    permit_mynetworks,  
 +    permit_sasl_authenticated,  
 +    reject_unauth_destination, 
 +    reject_non_fqdn_recipient, 
 +    reject_unknown_recipient_domain, 
 +    check_policy_service unix:private/policyd-spf
 </code> </code>
  
Line 353: Line 359:
 reject_unauthenticated_sender_login_mismatch, reject_unauthenticated_sender_login_mismatch,
 reject_sender_login_mismatch, reject_sender_login_mismatch,
 +check_sender_access hash:/etc/postfix/sender_access,
 permit permit
 </code> </code>
 +
 +The sender_access file is super helpful for repeat offenders. Sure, you can also just blacklist those in sieve rules, but that means that they still arrive and fill up your Junk folder. In some cases, spammers will send 100s of the same message per day. In those cases, it is helpful to stop them at the gates with postfix's sender_access:
 +
 +  nano /etc/postfix/sender_access
 +  <spam@domain.com     REJECT> #block exact email
 +  <domain.com          REJECT> #block all users @domain.com
 +  <.domain.com         REJECT> #block all users @sub.domain.com
 +  sudo postmap /etc/postfix/sender_access
 +  sudo postfix reload
 +  sudo systemctl restart postfix
  
 Now that the SPF/recipient and PTRI am now going to set up the DKIM policy for incoming email but/and, I will also use the same package to cut a DKIM keypair for use with the server's outgoing email. First, I install the policy and add opendkim to the postfix group. Now that the SPF/recipient and PTRI am now going to set up the DKIM policy for incoming email but/and, I will also use the same package to cut a DKIM keypair for use with the server's outgoing email. First, I install the policy and add opendkim to the postfix group.
Line 714: Line 731:
 } }
 # rule:[spamcheck] # rule:[spamcheck]
-if anyof (header :contains "x-spam-status" "Yes", header :contains "x-spam-flag" "YES", header :contains "x-spam-level" "*****")+if anyof (header :matches "x-spam-status" "Yes", header :contains "x-spam-flag" "YES", header :contains "x-spam-level" "*****")
 { {
  fileinto "Junk";  fileinto "Junk";
Line 1042: Line 1059:
 -- -- -- -- Miscellaneous Issues -- -- -- -- -- -- -- -- Miscellaneous Issues -- -- -- --
  
-To test sieve logic and rules, do the following:+To test sieve'logic and/or to test spamassassin's scoringdownload email (.eml) from Roundcube that did not behave as planned. Once you have the email, ''ssh'' into your mail server's simple unix user's mail directory and do the following:
  
 +  su - username
 +  cd ~/sieve
 +  spamassassin -t -D < Amazon1.eml 
 +  # this ^^ gives you the headers / spamassassin scores in stdout
 +  sieve-test -D -e roundcube.sieve Amazon3.eml 
 +  # this ^^ tests your sieve logic to see if the email goes in ham or spam
  
 +In the output that follows, look for something like the below. I put example output for each command above, respectively:
  
 +<code>
 +Content analysis details:   (16.9 points, 5.0 required)
 +
 + pts rule name              description
 +---- ---------------------- --------------------------------------------------
 + 0.8 DKIM_ADSP_ALL          No valid author signature, domain signs all mail
 + 0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
 +-0.0 SPF_PASS               SPF: sender matches SPF record
 + 0.2 BAYES_999              BODY: Bayes spam probability is 99.9 to 100%
 +                            [score: 1.0000]
 + 3.5 BAYES_99               BODY: Bayes spam probability is 99 to 100%
 +                            [score: 1.0000]
 + 2.0 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail
 +                            domains are different
 + 2.1 HTML_IMAGE_ONLY_12     BODY: HTML: images with 800-1200 bytes of words
 + 0.0 HTML_EXTRA_CLOSE       BODY: HTML contains far too many close tags
 + 0.1 MIME_HTML_ONLY         BODY: Message only has text/html MIME parts
 + 0.0 HTML_MESSAGE           BODY: HTML included in message
 + 2.0 RDNS_DYNAMIC           Delivered to internal network by host with
 +                            dynamic-looking rDNS
 + 0.0 HTML_SHORT_LINK_IMG_2  HTML is very short with a linked image
 + 3.6 HTML_TAG_BALANCE_CENTER Malformatted HTML
 + 0.4 HTML_MIME_NO_HTML_TAG  HTML-only message, but there is no HTML tag
 + 1.0 GOOG_STO_IMG_HTML      Apparently using google content hosting to avoid
 +                            URIBL
 + 1.2 DMARC_QUAR             DMARC quarantine policy
 + 0.0 T_REMOTE_IMAGE         Message contains an external image
 +</code>
 +
 +<code>
 +sieve-test: Debug: sieve: Commit fileinto action
 +sieve-test: Debug: sieve: fileinto action: Commit storing into mailbox 'Junk'
 +sieve-test: Info: sieve: msgid=<20250@psyb.info>: fileinto action: stored mail into mailbox 'Junk'
 +info: msgid=<20250@psyb.info>: fileinto action: stored mail into mailbox 'Junk'.
 +sieve-test: Debug: sieve: Finished finalizing actions (status=ok, keep=none, committed=yes)
 +</code>   
  
 ====== Part IX - What's next? ====== ====== Part IX - What's next? ======
Line 1059: Line 1119:
 I rewrote the mail server tutorial for the presentation [[https://tech.haacksnetworking.org/2025/06/10/your-email-your-rules-self-hosting-simplified/|Your Email, Your Rules: Self-Hosting Simplified]]. The SeaGL presentation can be found [[https://pretalx.seagl.org/2025/talk/VLM7AS/|on their calendar]]. I rewrote the mail server tutorial for the presentation [[https://tech.haacksnetworking.org/2025/06/10/your-email-your-rules-self-hosting-simplified/|Your Email, Your Rules: Self-Hosting Simplified]]. The SeaGL presentation can be found [[https://pretalx.seagl.org/2025/talk/VLM7AS/|on their calendar]].
  
- --- //[[alerts@haacksnetworking.org|oemb1905]] 2026/05/31 03:32//+ --- //[[alerts@haacksnetworking.org|oemb1905]] 2026/07/28 19:51//
computing/mailserver-trixie.1780199230.txt.gz · Last modified: by oemb1905