Skip to content

Commit

Permalink
✨ Rewrite as python smtpd extension
Browse files Browse the repository at this point in the history
  • Loading branch information
mraerino committed May 23, 2017
1 parent 918ada5 commit 2e55401
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 81 deletions.
3 changes: 0 additions & 3 deletions .gitignore

This file was deleted.

12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM zammad/zammad-docker-compose:zammad

ENV ZAMMAD_DIR /home/zammad

RUN apt-get update -qq && apt-get install -y python3

WORKDIR /smtp
ADD server.py /smtp/

EXPOSE 25

CMD ["python3", "server.py"]
56 changes: 0 additions & 56 deletions index.js

This file was deleted.

22 changes: 0 additions & 22 deletions package.json

This file was deleted.

22 changes: 22 additions & 0 deletions server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import asyncore
import os
from smtpd import SMTPServer
from subprocess import Popen, PIPE

class ZammadServer(SMTPServer):
def process_message(self, peer, mailfrom, rcpttos, data, **kwargs):
print(data)
pipe = Popen("bundle exec rails r 'Channel::Driver::MailStdin.new(trusted: true)'", shell=True, cwd=os.environ['ZAMMAD_DIR'], stdin=PIPE).stdin
pipe.write(data.encode('utf-8'))
pipe.close()

def run():
serv = ZammadServer(('0.0.0.0', 25), None)
try:
asyncore.loop()
except KeyboardInterrupt:
pass


if __name__ == '__main__':
run()

0 comments on commit 2e55401

Please sign in to comment.