#12: implement Antispam & Antivirus scanning pipeline (Rspamd & ClamAV)

This commit is contained in:
Lucas Rayan committed 2026-07-25 10:25:52 -03:00
1 parent 4c2e0b9563
commit 54d1ea5810
15 files changed
+825 -5

No files matched your search

@@ -7,6 +7,7 @@ import (
"context"
"errors"
"io"
"strings"
gosmtp "github.com/emersion/go-smtp"
@@ -108,6 +109,25 @@ func (s *session) Data(r io.Reader) error {
Body: r,
})
if err != nil {
var smtpErr *gosmtp.SMTPError
if errors.As(err, &smtpErr) {
return smtpErr
}
errMsg := err.Error()
if strings.HasPrefix(errMsg, "554 ") {
return &gosmtp.SMTPError{
Code: 554,
EnhancedCode: gosmtp.EnhancedCode{5, 7, 1},
Message: strings.TrimPrefix(errMsg, "554 5.7.1 "),
}
}
if strings.HasPrefix(errMsg, "451 ") {
return &gosmtp.SMTPError{
Code: 451,
EnhancedCode: gosmtp.EnhancedCode{4, 7, 1},
Message: strings.TrimPrefix(errMsg, "451 4.7.1 "),
}
}
return &gosmtp.SMTPError{
Code: 451,
EnhancedCode: gosmtp.EnhancedCode{4, 3, 0},