This documentation applies to the latest version of hitchsmtp.
HitchSMTP is a Hitch Plugin created to make testing applications that send emails easier.
- A Service to run a mock SMTP server that your application can be configured to send emails to.
$ hitch install hitchsmtp
Set up HitchSMTP¶
See also: Generic Service API
To use, define the service after initializing the Service Bundle:
import hitchsmtp self.services['HitchSMTP'] = hitchsmtp.HitchSMTPService( port=10025 # Optional (default: 10025) )
Once it is running, you can access the emails which arrived via the logs:
In : self.services['HitchSMTP'].logs.json() [ list of dicts of email contents and properties ]
You can also wait for emails to arrive by waiting for the logs:
In : email = self.services['HitchSMTP'].logs.out.tail.until_json( lambda email: "register: in email['payload'] or "register" in email['Subject'], timeout=5, lines_back=1, ) In : email [ dict of email contents and properties ]