Added some logging

master
Raoul Snyman 2021-10-28 19:31:34 -07:00
parent 3d1f1b6b6a
commit 4e1e9345a7
1 changed files with 4 additions and 0 deletions

View File

@ -30,6 +30,7 @@ class MailerHandlerMixin:
class KingMailerHandler(MailerHandlerMixin):
async def handle_DATA(self, server, session, envelope):
print('Incoming mesage from: {}'.format(envelope.mail_from))
payload = {
'mail_from': envelope.mail_from,
'rcpt_to': envelope.rcpt_tos,
@ -37,9 +38,12 @@ class KingMailerHandler(MailerHandlerMixin):
}
headers = {'X-Server-API-Key': self.api_token}
response = requests.post('https://api.kingmailer.co/api/v1/send/raw', data=payload, headers=headers)
print(response)
if response.ok:
print('Message accepted')
return '250 Message accepted for delivery'
else:
print('Could not process')
return '500 Could not process your message'