M
M
MrLokans2014-09-09 12:08:18
Python
MrLokans, 2014-09-09 12:08:18

How to know the output of a debug smtp server in Python?

The bottom line is this: there is a script that sends a letter through smtplib, which is configured for localhost and port 1025. The python debug server is running at the same address and port. The question is how to get the output of this server from the script? In words, it may not be clear, here are code snippets:

import subprocess
import shlex

command = 'python -m smtpd -n -c Debugging Server localhost:1025'
args = shlex.split(command)
p = subprocess.call(args, stdout=open('temp.txt', 'w'))
#здесь функция, которая отправляет почту через smplib.SMTP('localhost', 1025)
p.kill()

Accordingly, the temp.txt file is empty, although if you start the server through the terminal, the mail goes through and the message is displayed.
Along the way, a parallel question: is there any other way to debug on a local server without using non-standard modules?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Vasiliev, 2014-09-18
@qmax

What a horror.
Why do you need a separate server to send one message?
Why didn't you want to connect to a real server?

Y
Yuri Shikanov, 2015-01-02
@dizballanze

Try testing SMTP with the free debugmail service .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question