plain.mail
Everything you need to send email.
1"""
2Email message and email sending related helper functions.
3"""
4
5import socket
6
7from plain.utils.encoding import punycode
8
9
10# Cache the hostname, but do it lazily: socket.getfqdn() can take a couple of
11# seconds, which slows down the restart of the server.
12class CachedDnsName:
13 def __str__(self):
14 return self.get_fqdn()
15
16 def get_fqdn(self):
17 if not hasattr(self, "_fqdn"):
18 self._fqdn = punycode(socket.getfqdn())
19 return self._fqdn
20
21
22DNS_NAME = CachedDnsName()