def _mailPassword(self, email, reset_url): if not self.membertool.checkPermission('Mail forgotten password', self): raise Unauthorized, "Mailing forgotten passwords has been disabled." try: pwt = self.get_tool("portal_password_reset") mail_text = _(u'email_forgot_password', u'You requested a password reset for your ${portal_title} account. If you did not request this information, please ignore this message.\n\nTo change your password, please visit the following URL: ${url}', mapping={u'url':reset_url}) sender = EmailSender(self, secureSend=True) sender.sendEmail(mto=email, msg=mail_text, subject=_(u'email_forgot_password_subject', u'${portal_title} - Password reset', mapping={u'portal_title':self.portal_title()})) except SMTPRecipientsRefused: # Don't disclose email address on failure # XXX is this needed? raise SMTPRecipientsRefused('Recipient address rejected by server')
def _send_mail_to_pending_user(self, user_name, email, url): """ send a mail to a pending user """ # TODO only send mail if in the pending workflow state root = getToolByName(self.context, 'portal_url')() if isinstance(user_name, str): user_name = user_name.decode("utf8") message = _(u'email_to_pending_user', mapping={u'user_name':user_name, u'url':url, u'portal_url':root, u'portal_title':self.portal_title()}) subject = _(u'email_to_pending_user_subject', mapping={u'user_name':user_name, u'url':url, u'portal_url':root, u'portal_title':self.portal_title()}) sender = EmailSender(self.portal, secureSend=True) sender.sendEmail(mto=email, msg=message, subject=subject)