Check contents of SMTP Requests

32 views
Skip to first unread message

Tim Lane

unread,
Dec 16, 2021, 8:36:06 PM12/16/21
to mountebank-discuss
Hi All,

I have setup a smtp mock server and want to be able to check the contents of the requests but while I can see it's updating the number of requests does not have any contents information.

config file:
{
  "port": 2500,
  "protocol": "smtp",
  "recordRequests": true
}

Command Line:
node.exe \mountebank\bin\mb --configfile imposters.ejs --allowInjection --port 12001 --logfile mb_smtp.log

I then send an email which is received as per the log file:
{"level":"info","message":"[smtp:2500] ::ffff:127.0.0.1 => Envelope from: fro...@fab.com.au to: [\"to...@fabperformancetesting.com\"]","timestamp":"2021-12-17T01:20:35.738Z"}

But when the call for the requests it has no contents although the number of requests increases:
{
  "protocol": "smtp",
  "port": 2500,
  "numberOfRequests": 2,
  "requests": [],
  "stubs": [],
  "_links": {
    "self": {
      "href": "http://localhost:12001/imposters/2500"
    }
  }
}


Any idea what I'm doing wrong?



Brandon Byars

unread,
Dec 16, 2021, 9:35:50 PM12/16/21
to Tim Lane, mountebank-discuss
By default, mountebank doesn’t record the actual request because, in long-running scenarios, that’s also called a “memory leak.”  If you add “recordRequests: true” to the imposter configuration, it will save the request from information. 

--
You received this message because you are subscribed to the Google Groups "mountebank-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mountebank-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mountebank-discuss/58fe6add-c18d-4d57-8e49-d26e3e73e081n%40googlegroups.com.
--
Sent from Gmail Mobile

Tim Lane

unread,
Dec 16, 2021, 10:14:11 PM12/16/21
to mountebank-discuss
thanks for the prompt response. 

Your suggestion didn't bear fruit however, I upgraded to a later version and it works just fine now :)

While i've got you :) if I wanted to write the contents of an email to a datastore (say redis) is that possible with mock services?

Tim.

Brandon Byars

unread,
Dec 21, 2021, 10:59:17 AM12/21/21
to Tim Lane, mountebank-discuss
Yes, that behavior changed over time. It used to be that you'd have to pass the --mock CLI flag on startup (that still works, but is no longer documented and I consider it deprecated behavior).

Externalizing the persistence is a big goal of mine, but I'd like to do it through a plugin architecture (someone is actually playing around with that idea now). It's no mean feat: you'd have to reimplement the implicit interface defined in this file: https://github.com/bbyars/mountebank/blob/master/src/models/filesystemBackedImpostersRepository.js.
-Brandon

Reply all
Reply to author
Forward
0 new messages