Commit f217540e authored by Hugo Hörnquist's avatar Hugo Hörnquist
Browse files

Initial commit.

import smtpd
import asyncore
from email import message_from_bytes
import email.policy
from dateutil.parser import parse
import subprocess
class CustomSMTPServer(smtpd.SMTPServer):
def process_message(self, peer, mailfrom, rcpttos, data, **kwargs):
msg = message_from_bytes(data, policy=email.policy.default)
body = msg.get_content()
d = parse(msg.get('Date'))
title = msg.get('Subject')'wp', 'post', 'create',
'--post_author', 1,
'--post_date', f'{d:%Y-%m-%d}',
'--post_title', title,
'--post_publish', 'publish',
'--post_category', 'Veckomail',
'--post_content', f'<pre>{body}</pre>')
server = CustomSMTPServer(('localhost', 1025), None,
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment