from .xlate import XLATOR
-__version__ = '0.1.1'
+__version__ = '0.1.2'
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext
msg = _("Evaluating config section {!r}:").format(section_name)
LOG.debug(msg + '\n' + pp(section))
+ self._eval_mail_from(section_name, section)
self._eval_mail_rcpt(section_name, section)
self._eval_mail_cc(section_name, section)
self._eval_mail_reply_to(section_name, section)
return result
+ # -------------------------------------------------------------------------
+ def _eval_mail_from(self, section_name, section):
+
+ re_from = re.compile(r'^\s*(mail[_-]?)?from\s*$', re.IGNORECASE)
+
+ for key in section.keys():
+ if not re_from.search(key):
+ continue
+
+ val = section[key]
+
+ if is_sequence(val):
+ if not len(val):
+ continue
+ val = val[0]
+
+ if MailAddress.valid_address(val):
+ self.mail_from = val
+ else:
+ msg = _("Found invalid {what} {addr!r} in configuration.")
+ LOG.error(msg.format(what=_("from address"), addr=val))
+
# -------------------------------------------------------------------------
def _eval_mail_rcpt(self, section_name, section):