Index: /main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py
===================================================================
--- /main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py	(revision 7401)
+++ /main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py	(revision 7402)
@@ -219,16 +219,16 @@
         fullname = self.request.principal.title
         try:
-            email_from = self.request.principal.email
+            email = self.request.principal.email
         except AttributeError:
-            email_from = self.config.email_admin
+            email = self.config.email_admin
         username = self.request.principal.id
         usertype = getattr(self.request.principal,
                            'user_type', 'system').title()
-        body = data['body']
-        email_to = self.config.email_admin
-        subject = self.config.email_subject
         sirp_utils = getUtility(ISIRPUtils)
-        success = sirp_utils.sendMail(fullname,username,usertype,
-                  self.config.name,body,email_from,email_to,subject)
+        success = sirp_utils.sendMail(
+                fullname,email,
+                self.config.name_admin,self.config.email_admin,
+                username,usertype,self.config.name,
+                data['body'],self.config.email_subject)
         if success:
             self.flash('Your message has been sent.')
@@ -246,14 +246,10 @@
     @grok.action('Send now')
     def send(self, *args, **data):
-        email_from = data['email_from']
-        fullname = data['fullname']
-        body = data['body']
-        username = u'None'
-        email_to = self.config.email_admin
-        subject = self.config.email_subject
-        usertype = u'Anonymous'
         sirp_utils = getUtility(ISIRPUtils)
-        success = sirp_utils.sendMail(fullname,username,usertype,
-                  self.config.name,body,email_from,email_to,subject)
+        success = sirp_utils.sendMail(
+                data['fullname'],data['email_from'],
+                self.config.name_admin,self.config.email_admin,
+                u'None',u'Anonymous',self.config.name,
+                data['body'],self.config.email_subject)
         if success:
             self.flash('Your message has been sent.')
@@ -467,18 +463,16 @@
     @grok.action('Send message now')
     def send(self, *args, **data):
-        fullname = self.request.principal.title
         try:
-            email_from = self.request.principal.email
+            email = self.request.principal.email
         except AttributeError:
-            email_from = self.config.email_admin
-        username = self.request.principal.id
+            email = self.config.email_admin
         usertype = getattr(self.request.principal,
                            'user_type', 'system').title()
-        body = data['body']
-        email_to = self.context.email
-        subject = self.config.email_subject
         sirp_utils = getUtility(ISIRPUtils)
-        success = sirp_utils.sendMail(fullname,username,usertype,
-                  self.config.name,body,email_from,email_to,subject)
+        success = sirp_utils.sendMail(
+                self.request.principal.title,email,
+                self.context.title,self.context.email,
+                self.request.principal.id,usertype,self.config.name,
+                data['body'],self.config.email_subject)
         if success:
             self.flash('Your message has been sent.')
Index: /main/waeup.sirp/trunk/src/waeup/sirp/utils/utils.py
===================================================================
--- /main/waeup.sirp/trunk/src/waeup/sirp/utils/utils.py	(revision 7401)
+++ /main/waeup.sirp/trunk/src/waeup/sirp/utils/utils.py	(revision 7402)
@@ -28,5 +28,5 @@
 from email.Utils import parseaddr, formataddr
 
-def send_mail(from_name,from_email,rcpt_name,rcpt_email,subject,body,config):
+def send_mail(from_name,from_addr,rcpt_name,rcpt_addr,subject,body,config):
     """
     XXX: While this method is unicode-proof (i.e. it can handle
@@ -37,8 +37,4 @@
 
     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))
@@ -63,5 +59,5 @@
         server.login(config.smtp_username,config.smtp_password)
     try:
-        server.sendmail(from_email,rcpt_email,msg.as_string())
+        server.sendmail(from_addr,rcpt_addr,msg.as_string())
     except Exception, e:
         # XXX: log error message
@@ -76,6 +72,6 @@
     grok.implements(ISIRPUtils)
 
-    def sendMail(self,fullname,username,usertype,portal,body,
-                 email_from,email_to,subject):
+    def sendMail(self,from_name,from_addr,rcpt_name,rcpt_addr,
+                from_username,usertype,portal,body,subject):
         """Send an email with data provided by forms.
         """
@@ -88,11 +84,7 @@
 %s
 """
-        from_name = fullname
-        from_email = email_from
-        rcpt_name = 'xyz'
-        rcpt_email = email_to
-        body = text % (fullname,username,usertype,portal,body)
+        body = text % (from_name,from_username,usertype,portal,body)
         return send_mail(
-            from_name,from_email,rcpt_name,rcpt_email,subject,body,config)
+            from_name,from_addr,rcpt_name,rcpt_addr,subject,body,config)
 
     def fullname(self,firstname,lastname,middlename=None):
@@ -139,12 +131,9 @@
         config = grok.getSite()['configuration']
         from_name = config.name_admin
-        from_email = config.email_admin
+        from_addr = config.email_admin
         rcpt_name = applicant.display_fullname
-        rcpt_email = applicant.email
+        rcpt_addr = 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)
-
-
-
+            from_name,from_addr,rcpt_name,rcpt_addr,subject,body,config)
