def _fetch_showq(self):
"""Connect to Postfix showq inet daemon and retrieve queue.
This method is faster than executing mailq because it doesn't fork
processes.
It requires to have showq inet daemon activated which is not the case
by default. To make showq listen on the loopback interface on port
4280, add to your master.cf:
127.0.0.1:4280 inet n - - - - showq
"""
showq = bytes()
with socket.create_connection((self.config['host'],
self.config['port']),
timeout=self.config['timeout']) as s:
while True:
buffer = bytearray(4096)
bytes_received = s.recv_into(buffer)
if bytes_received == 0:
break
showq += buffer
return showq.decode(encoding='utf-8')
评论列表
文章目录