Mercurial > libervia-backend
changeset 1765:b9493cb6ce49
plugin misc_account: fixes login messages when sending emails
author | souliane <souliane@mailoo.org> |
---|---|
date | Tue, 22 Dec 2015 16:20:25 +0100 |
parents | 33c815c17fe6 |
children | d17772b0fe22 |
files | src/plugins/plugin_misc_account.py |
diffstat | 1 files changed, 14 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/plugin_misc_account.py Tue Dec 22 11:44:51 2015 +0100 +++ b/src/plugins/plugin_misc_account.py Tue Dec 22 16:20:25 2015 +0100 @@ -230,28 +230,21 @@ def sendEmails(self, email, jid_s, password, profile): # time to send the email - _email_host = self.getConfig('email_server') - _email_from = self.getConfig("email_from") + email_host = self.getConfig('email_server') + email_from = self.getConfig("email_from") domain = self.getConfig('new_account_domain') - - def email_ok(ignore): - log.debug(u"Account creation email sent to %s" % email) - - def email_ko(ignore): - # TODO: return error code to user - log.error(u"Failed to send email to %s" % email) - # email to the administrator body = (u"""New account created: %(profile)s [%(email)s]""" % {'profile': profile, 'email': email}).encode('utf-8') msg = MIMEText(body, 'plain', 'UTF-8') msg['Subject'] = _('New Libervia account created') - msg['From'] = _email_from + msg['From'] = email_from msg['To'] = self.getConfig('admin_email') - d_admin = sendmail(_email_host, _email_from, self.getConfig('admin_email'), msg.as_string()) - d_admin.addCallbacks(email_ok, email_ko) - + admin_email = self.getConfig('admin_email') + d_admin = sendmail(email_host, email_from, admin_email, msg.as_string()) + d_admin.addCallbacks(lambda dummy: log.debug(u"Account creation notification sent to admin <%s>" % admin_email), + lambda dummy: log.error(u"Failed to send account creation notification to admin <%s>" % admin_email)) if not email: return d_admin @@ -279,12 +272,16 @@ """) % {'profile': profile, 'jid_s': jid_s, 'domain': domain}).encode('utf-8') msg = MIMEText(body, 'plain', 'UTF-8') msg['Subject'] = _(u'Libervia account created') - msg['From'] = _email_from + msg['From'] = email_from msg['To'] = email - d_user = sendmail(_email_host, _email_from, email, msg.as_string()) - d_user.addCallbacks(email_ok, email_ko) + def email_ko(dummy): + # TODO: return error code to user + log.error(u"Failed to send account creation confirmation to <%s>" % email) + d_user = sendmail(email_host, email_from, email, msg.as_string()) + d_user.addCallbacks(lambda dummy: log.debug(u"Account creation confirmation sent to <%s>" % email), + email_ko) return defer.DeferredList([d_user, d_admin]) def getNewAccountDomain(self):