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

Initial commit.

parents
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')
subprocess.run('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>')
return
server = CustomSMTPServer(('localhost', 1025), None,
decode_data=False)
asyncore.loop()
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