Mercurial > public > mercurial-scm > hg-stable
diff mercurial/ui.py @ 2200:9f43b6e24232
move mail sending code into core, so extensions can share it.
document hgrc settings used.
author | Vadim Gelfer <vadim.gelfer@gmail.com> |
---|---|
date | Thu, 04 May 2006 12:23:01 -0700 |
parents | d0c02b4dce9a |
children | f15056b29472 |
line wrap: on
line diff
--- a/mercurial/ui.py Thu May 04 12:02:32 2006 -0700 +++ b/mercurial/ui.py Thu May 04 12:23:01 2006 -0700 @@ -8,7 +8,7 @@ import ConfigParser from i18n import gettext as _ from demandload import * -demandload(globals(), "errno os re socket sys tempfile util") +demandload(globals(), "errno os re smtplib socket sys tempfile util") class ui(object): def __init__(self, verbose=False, debug=False, quiet=False, @@ -264,3 +264,17 @@ os.unlink(name) return t + + def sendmail(self): + s = smtplib.SMTP() + s.connect(host = self.config('smtp', 'host', 'mail'), + port = int(self.config('smtp', 'port', 25))) + if self.configbool('smtp', 'tls'): + s.ehlo() + s.starttls() + s.ehlo() + username = self.config('smtp', 'username') + password = self.config('smtp', 'password') + if username and password: + s.login(username, password) + return s