Index: /main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py
===================================================================
--- /main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py	(revision 7398)
+++ /main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py	(revision 7399)
@@ -1059,8 +1059,10 @@
         self.applyData(applicant, **data)
         self.context.addApplicant(applicant)
-        password = getUtility(ISIRPUtils).genPassword()
+        sirp_utils = getUtility(ISIRPUtils)
+        password = sirp_utils.genPassword()
         IUserAccount(applicant).setPassword(password)
         # Send email with credentials
-        if self.sendCredentials(applicant, password):
+        login_url = self.url(grok.getSite(), 'login')
+        if sirp_utils.sendCredentials(applicant, password, login_url):
             self.redirect(self.url(self.context, 'registration_complete',
                                    data = dict(email=applicant.email)))
@@ -1069,23 +1071,4 @@
             self.flash('Email could not been sent. Please retry later.')
         return
-
-    def sendCredentials(self, applicant, password):
-        """Send credentials as email.
-
-        Input is the applicant for which credentials are sent and the
-        password.
-
-        Returns True or False to indicate successful operation.
-        """
-        sirp_utils = getUtility(ISIRPUtils)
-        username = applicant.applicant_id
-        fullname = applicant.display_fullname
-        subject = 'Your SIRP credentials'
-        msg = 'You have successfully been registered for the'
-        email_to = applicant.email
-        login_url = self.url(grok.getSite(), 'login')
-        success = sirp_utils.sendPassword(fullname,msg,username,
-            password,login_url,email_to,subject)
-        return success
 
 class ApplicantRegistrationEmailSent(SIRPPage):
Index: /main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser_templates/applicantregemailsent.pt
===================================================================
--- /main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser_templates/applicantregemailsent.pt	(revision 7398)
+++ /main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser_templates/applicantregemailsent.pt	(revision 7399)
@@ -6,5 +6,5 @@
   <p>
     An email with your user name and password
-    has been sent to <span tal:replace="view/email">user@foo.baz</span>
+    has been sent to <span tal:replace="view/email">user@foo.baz</span>.
   </p>
   <p>
@@ -12,4 +12,5 @@
   </p>
   <p>
-    Thanks for using SIRP.
+    Thanks for using SIRP!
+  </p>
 </div>
Index: /main/waeup.sirp/trunk/src/waeup/sirp/utils/utils.py
===================================================================
--- /main/waeup.sirp/trunk/src/waeup/sirp/utils/utils.py	(revision 7398)
+++ /main/waeup.sirp/trunk/src/waeup/sirp/utils/utils.py	(revision 7399)
@@ -27,4 +27,40 @@
 from email.Header import Header
 from email.Utils import parseaddr, formataddr
+
+def send_mail(from_name,from_email,rcpt_name,rcpt_email,subject,body,config):
+
+    header_charset = 'ISO-8859-1'
+    from_ = '%s <%s>' % (from_name,from_email)
+    to_ = '%s <%s>' % (rcpt_name,rcpt_email)
+    from_name, from_addr = parseaddr(from_)
+    rcpt_name, rcpt_addr = parseaddr(to_)
+    from_name = str(Header(unicode(from_name), header_charset))
+    rcpt_name = str(Header(unicode(rcpt_name), header_charset))
+    from_addr = from_addr.encode('ascii')
+    rpct_addr = rcpt_addr.encode('ascii')
+
+    for body_charset in ['US-ASCII', 'ISO-8859-1', 'UTF-8']:
+        try:
+            body.encode(body_charset)
+        except UnicodeError:
+            print "FAILED: ", body_charset, text
+            pass
+        else:
+            break
+
+    msg = MIMEText(body.encode(body_charset), 'plain', body_charset)
+    msg['From'] = formataddr((from_name, from_addr))
+    msg['To'] = formataddr((rcpt_name, rcpt_addr))
+    msg['Subject'] = Header(unicode(subject), header_charset)
+    server = smtplib.SMTP(config.smtp_server)
+    if config.smtp_requires_login:
+        server.login(config.smtp_username,config.smtp_password)
+    try:
+        server.sendmail(from_email,rcpt_email,msg.as_string())
+    except Exception, e:
+        # XXX: log error message
+        return False
+    server.quit()
+    return True
 
 
@@ -72,7 +108,12 @@
         return ''.join([r().choice(chars) for i in range(length)])
 
-    def sendPassword(self,fullname,msg,username,password,login_url,
-                 email_to,subject):
-        """Send an email with user credentials.
+
+    def sendCredentials(self, applicant, password, login_url):
+        """Send credentials as email.
+
+        Input is the applicant for which credentials are sent and the
+        password.
+
+        Returns True or False to indicate successful operation.
 
         XXX: While this method is unicode-proof (i.e. it can handle
@@ -81,6 +122,7 @@
              reorganization of SMPT-related code is needed here.
         """
-        config = grok.getSite()['configuration']
-        header_charset = 'ISO-8859-1'
+        username = applicant.applicant_id
+        subject = 'Your SIRP credentials'
+        msg = 'You have successfully been registered for the'
         text = """Dear %s,
 
@@ -100,35 +142,14 @@
 Regards
 """
-        from_ = '%s <%s>' % (config.name_admin,config.email_admin)
-        from_name, from_addr = parseaddr(from_)
-        rcpt_name, rcpt_addr = parseaddr(email_to)
-        from_name = str(Header(unicode(from_name), header_charset))
-        rcpt_name = str(Header(unicode(rcpt_name), header_charset))
-        from_addr = from_addr.encode('ascii')
-        rpct_addr = rcpt_addr.encode('ascii')
+        config = grok.getSite()['configuration']
+        from_name = config.name_admin
+        from_email = config.email_admin
+        rcpt_name = applicant.display_fullname
+        rcpt_email = applicant.email
+        body = text % (
+                rcpt_name, msg,config.name,username,password,login_url)
+        return send_mail(
+            from_name,from_email,rcpt_name,rcpt_email,subject,body,config)
 
-        body = text % (
-                fullname, msg,config.name,username,password,login_url)
-        for body_charset in ['US-ASCII', 'ISO-8859-1', 'UTF-8']:
-            try:
-                body.encode(body_charset)
-            except UnicodeError:
-                print "FAILED: ", body_charset, text
-                pass
-            else:
-                break
 
-        msg = MIMEText(body.encode(body_charset), 'plain', body_charset)
-        msg['From'] = formataddr((from_name, from_addr))
-        msg['To'] = formataddr((rcpt_name, rcpt_addr))
-        msg['Subject'] = Header(unicode(subject), header_charset)
-        server = smtplib.SMTP(config.smtp_server)
-        if config.smtp_requires_login:
-            server.login(config.smtp_username,config.smtp_password)
-        try:
-            server.sendmail(config.email_admin,email_to,msg.as_string())
-        except Exception, e:
-            # XXX: log error message
-            return False
-        server.quit()
-        return True
+
