public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Brian Dolbec" <dolsen@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gentoo-keys:gsoc-2016 commit in: gkeys/gkeys/
Date: Fri, 23 Dec 2016 08:37:13 +0000 (UTC)	[thread overview]
Message-ID: <1472326970.8fea35a1e65ebab3e11245d88c58e08cb84c57a2.dolsen@gentoo> (raw)

commit:     8fea35a1e65ebab3e11245d88c58e08cb84c57a2
Author:     aeroniero33 <justthisthing <AT> gmail <DOT> com>
AuthorDate: Sat Aug 27 14:07:07 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Aug 27 19:42:50 2016 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=8fea35a1

Added a mail script that handles the emailing proccess

I created a new file called `mail.py` that handles the email login and the email sending.

 gkeys/gkeys/mail.py | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/gkeys/gkeys/mail.py b/gkeys/gkeys/mail.py
new file mode 100644
index 0000000..df86d11
--- /dev/null
+++ b/gkeys/gkeys/mail.py
@@ -0,0 +1,51 @@
+from __future__ import print_function
+
+import os
+import smtplib
+import sys
+import email.utils
+
+from email.mime.text import MIMEText
+from snakeoil.demandload import demandload
+
+if sys.version_info[0] >= 3:
+    py_input = input
+    _unicode = str
+else:
+    py_input = raw_input
+    _unicode = unicode
+
+demandload(
+    "gkeys.base:Args",
+    "json:load",
+)
+
+class Emailer(object):
+    '''Send an email reminder about the status of the user's GPG key'''
+
+    def __init__(self, login, logger):
+        self.logger = logger
+        self.email_from = _unicode(login['login_email'])
+        self.sender_full_name = _unicode(login['full_name'])
+        login_passwd = login['passwd']
+        server = login['server']
+        self.mail = smtplib.SMTP(server, 587)
+        self.mail.ehlo()
+        self.mail.starttls()
+        self.mail.login(self.email_from, login_passwd)
+        self.logger.debug(_unicode("Login successfull"))
+
+    def send_email(self, uid, message):
+        self.logger.debug(_unicode('Sending email with message %s') % _unicode(message))
+        subject = "Expiring Key"
+        email_to = uid
+        msg = MIMEText(message, 'plain')
+        msg['Subject'] = subject
+        msg['From'] = email.utils.formataddr((self.sender_full_name, self.email_from))
+        msg['To'] = email_to
+        self.logger.info(_unicode('Sending the email reminder from %s to %s') \
+            % (self.email_from, email_to))
+        self.mail.sendmail(self.email_from, email_to, msg.as_string())
+
+    def email_quit(self):
+        self.mail.quit()


             reply	other threads:[~2016-12-23  8:37 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-23  8:37 Brian Dolbec [this message]
  -- strict thread matches above, loose matches on Subject: below --
2016-12-24  9:41 [gentoo-commits] proj/gentoo-keys:gsoc-2016 commit in: gkeys/gkeys/ Brian Dolbec
2016-12-24  9:41 Brian Dolbec
2016-12-24  9:41 Brian Dolbec
2016-12-24  9:41 Brian Dolbec
2016-12-24  9:41 Brian Dolbec
2016-12-24  9:41 Brian Dolbec
2016-12-24  9:41 Brian Dolbec
2016-12-24  9:41 Brian Dolbec
2016-12-24  9:41 Brian Dolbec
2016-12-24  9:13 Brian Dolbec
2016-12-24  9:13 Brian Dolbec
2016-12-24  9:13 Brian Dolbec
2016-12-24  9:13 Brian Dolbec
2016-12-24  9:13 Brian Dolbec
2016-12-24  9:13 Brian Dolbec
2016-12-24  9:13 Brian Dolbec
2016-12-24  9:13 Brian Dolbec
2016-12-24  9:13 Brian Dolbec
2016-12-24  9:13 Brian Dolbec
2016-12-24  9:13 Brian Dolbec
2016-12-24  9:13 Brian Dolbec
2016-12-24  9:13 Brian Dolbec
2016-12-24  9:13 Brian Dolbec
2016-12-24  9:13 Brian Dolbec
2016-12-24  9:13 Brian Dolbec
2016-12-24  9:13 Brian Dolbec
2016-12-24  4:52 [gentoo-commits] proj/gentoo-keys:master " Brian Dolbec
2016-12-24  9:13 ` [gentoo-commits] proj/gentoo-keys:gsoc-2016 " Brian Dolbec
2016-12-23  8:37 Brian Dolbec
2016-12-23  8:37 Brian Dolbec
2016-12-23  8:37 Brian Dolbec
2016-12-23  8:37 Brian Dolbec
2016-12-23  8:37 Brian Dolbec
2016-12-23  8:37 Brian Dolbec
2016-12-23  8:37 Brian Dolbec
2016-12-23  8:37 Brian Dolbec
2016-12-23  8:37 Brian Dolbec
2016-12-23  8:37 Brian Dolbec
2016-12-23  8:37 Brian Dolbec
2016-12-23  8:37 Brian Dolbec

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1472326970.8fea35a1e65ebab3e11245d88c58e08cb84c57a2.dolsen@gentoo \
    --to=dolsen@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox