close method

Future<void> close()

Stops accepting connections and drops the ones still open, then waits a few seconds at most for the mails already received to reach the relay. Whatever the relay has not taken by then is abandoned without an error.

Implementation

Future<void> close() async {
  if (_closed) return;
  _closed = true;
  await _subscription.cancel();
  await _server.close();
  for (var session in _sessions.toList()) {
    session.end();
  }
  await _relayQueue.timeout(
    _drainTimeout,
    onTimeout: () {
      _relayAbandoned = true;
      _relaying?.destroy();
    },
  );
}