This solution uses 'postqueue -j' command, which will produce an
empty list for stdout only when there are no more emails in the
queue. We become independent of the format of the output (byte,
string, specific characters, etc)
run_cmd(cmd='postqueue -f', vm=vm)
log.info('Waiting for SMTP queue to be empty (%i/%i sec)',
i, timeout)
- if b'Mail queue is empty' in run_cmd(cmd='mailq', vm=vm).stdout:
+ if not run_cmd(cmd='postqueue -j', vm=vm).stdout:
break
time.sleep(1)
log.debug('SMTP queue is empty')