Skip to content

Commit 93109de

Browse files
WIP: Answering with SMTP error code, for testing
Closes axllent#402 My knowledge of Go is (in your syntax): `nil` But I'm sure you get the idea :-) Based on your comment at axllent#402 (comment) > the email would need to have already been processed in order to process the addresses I'm *guessing* that maybe you aren't using the address given at `MAIL FROM` at all. If this is indeed the case, then it certainly would be easy to capture the contents of your `mailFromRE`s first parentheses into some variable.
1 parent 0fbb946 commit 93109de

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

server/smtpd/lib.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,14 @@ loop:
405405
break
406406
}
407407

408+
errorMailFromRE = regexp.MustCompile(`_mailpit_smtp_reply_code_(\d\d\d)_after_mail_from@example\.com`)
409+
match := errorMailFromRE.FindStringSubmatch(args)
410+
if match {
411+
// match[1] is meant to be the content of the first parentheses in the pattern:
412+
s.writef(match[1] . " Answering with the STMP status code you requested in the MAIL FROM address")
413+
break
414+
}
415+
408416
match := mailFromRE.FindStringSubmatch(args)
409417
if match == nil {
410418
s.writef("501 5.5.4 Syntax error in parameters or arguments (invalid FROM parameter)")

0 commit comments

Comments
 (0)