Package: mailhog
mailhog-pythonA python client for theMailhogAPIInstallationInstall from PyPIpip install mailhogGet StartedfrommailhogimportMailhogmailhog=Mailhog()# Defaults to http://localhost:8025# Get all messagesmailhog.messages()# Get all messages with start and limit parametersmailhog.messages(start=0,limit=10)# Search for messagesmailhog.search('Text contained in the message')# Search for messages by recipientmailhog.search('test@test.com','To')# Search for messages by sendermailhog.search('test@test.com','From')# Delete all messagesmailhog.delete_all()APImailhog.MailhogMailhog API clientParametershost- The host of the Mailhog API, defaults tolocalhostport- The port of the Mailhog API, defaults to8025Methodsmessages(start=0, limit=10)Get all messagesParametersstart- The start index of the messages to return, defaults to0limit- The number of messages to return, defaults to10Returnslist- A list ofmailhog.MessageobjectsExamplefrommailhogimportMailhogmailhog=Mailhog()messages=mailhog.messages()search(query, kind='containing', start=0, limit=10)Search for messagesParametersquery- The query to search forkind- The kind of search to perform, defaults tocontainingstart- The start index of the messages to return, defaults to0limit- The number of messages to return, defaults to10Returnslist- A list ofmailhog.MessageobjectsExamplefrommailhogimportMailhogmailhog=Mailhog()messages=mailhog.search('Some Text')delete_all()Delete all messagesExamplefrommailhogimportMailhogmailhog=Mailhog()mailhog.delete_all()Datatypesmailhog.MessagesA list ofmailhog.MessageobjectsAttributestotal- The total number of messagesstart- The start index of the messagescount- The total number of received messagesitems- A list ofmailhog.Messageobjectsmailhog.MessageA message from MailhogAttributesid- The ID of the messagefrom_- A mailhog.Path object containing the senderto- A List of mailhog.Path objects containing the recipientscreated- The date the message was createdcontent- A mailhog.Content object containing the content of the messageraw: - The raw messagemime- A mailhog.MIME object containing the MIME data of the messageMethodsget_sender()Get the sender of the messageReturnsstr- The sender of the messageget_recipients()Get the recipients of the messageReturnslist- A list of recipientsget_subject()Get the subject of the messageReturnsstr- The subject of the messagemailhog.PathA path objectAttributesrelays- A list of relaysmailbox- The mailboxdomain- The domainparams- The parametersmailhog.ContentThe content of a messageAttributesheaders- A Dict of headers of the messagebody- The body of the messagesize- The size of the messagemime- The MIME type of the messagemailhog.MIMEBodyThe body of a MIME messageAttributesparts- A list of mailhog.MIMEContent objectsmailhog.MIMEContentThe content of a MIME messageAttributesheaders- A Dict of headers of the messagebody- The body of the messagesize- The size of the messagemime- The MIME type of the messageAbout the PackageWIPThis package is still a work in progress. If you find any bugs or have any suggestions, please open an issue on theGitHub repositoryRoadmapMailhog API v2 Messages EndpointMailhog API v2 Search EndpointMailhog API v2 Jim EndpointMailhog API v1 Delete Messages EndpointMailhog API v1 Delete Message EndpointLocal DevelopmentTo install the package locally, run the following commands:git clone
cd mailhog-python

poetry installTo run a mailhog instance locally, run the following command:docker-compose up -dTo run the tests, run the following command:poetry run pytest