aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatarChristoph Goehre <christoph.goehre@gmx.de>2009-03-15 18:42:32 +0100
committerLibravatarChristoph Goehre <christoph.goehre@gmx.de>2009-03-15 18:42:32 +0100
commitb514d386c889b874a733d107ad28d49babb38630 (patch)
tree92cf292784ab9171e57721de1f7252c973c8f7bf
parent0607dbf1c94fc90028024ab80190d5113266ae48 (diff)
send upload information mails with utf-8 charset
With the release of Lenny, all changelog file must be UTF-8[1], so we can encode upload emails also as utf-8. This avoid broken Uploaders/Maintainers information. [1] http://release.debian.org/lenny/goals.txt Closes: #505144
-rwxr-xr-xmini-dinstall4
-rw-r--r--minidinstall/mail.py43
2 files changed, 45 insertions, 2 deletions
diff --git a/mini-dinstall b/mini-dinstall
index ad49c47..26bb7c5 100755
--- a/mini-dinstall
+++ b/mini-dinstall
@@ -32,6 +32,7 @@ from minidinstall.DebianSigVerifier import *
from minidinstall.GPGSigVerifier import *
from minidinstall.version import *
import minidinstall.misc
+import minidinstall.mail
debchanges_re = re.compile('([-a-z0-9+.]+)_(.+?)_([-a-zA-Z0-9]+)\.changes$')
debpackage_re = re.compile('([-a-z0-9+.]+)_(.+?)_([-a-zA-Z0-9]+)\.u?deb$')
@@ -812,8 +813,7 @@ class ArchiveDir:
done = True
if missing_fields:
mail_body = mail_body + "\n\nMissing changefile fields: %s" % missing_fields
- self.mailHandler.setSubject(mail_subject)
- self._success_logger.info(mail_body)
+ minidinstall.mail.send(mail_server, 'Mini-Dinstall <%s@%s>' % (getpass.getuser(),socket.getfqdn()), mail_to, mail_body, mail_subject)
if self._post_install_script:
try:
diff --git a/minidinstall/mail.py b/minidinstall/mail.py
new file mode 100644
index 0000000..d1c7c0a
--- /dev/null
+++ b/minidinstall/mail.py
@@ -0,0 +1,43 @@
+# mail -*- mode: python; coding: utf-8 -*-
+
+"""Simple mail support for mini-dinstall."""
+
+# Copyright © 2008 Stephan Sürken <absurd@debian.org>
+
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+import smtplib
+import email.mime.text
+
+import logging
+
+def send(smtp_server, smtp_from, smtp_to, body, subject="mini-dinstall mail notice"):
+ """Send email; on error, log and continue."""
+
+ logger = logging.getLogger("mini-dinstall")
+
+ try:
+ # Create a mime body
+ mime_body = email.mime.text.MIMEText(body, 'plain', 'utf-8')
+ mime_body['Subject'] = subject
+ mime_body['From'] = smtp_from
+ mime_body['To'] = smtp_to
+
+ # Send via SMTP server
+ smtp = smtplib.SMTP(smtp_server)
+ smtp.sendmail(smtp_from, [smtp_to], mime_body.as_string())
+ logger.info("Mail sent to %s (%s)" % (smtp_to, subject))
+ except Exception, e:
+ logger.exception("Error sending mail to %s ('%s') via %s: %s: %s", smtp_to, subject, smtp_server, type(e), e.args)