mango r182 - in trunk: . lib templates www



Author: ovitters
Date: Sun Jun  1 10:32:10 2008
New Revision: 182
URL: http://svn.gnome.org/viewvc/mango?rev=182&view=rev

Log:
	Add configuration options for mail backend. Patch by Patrick Fey
	with slight modifications by me.
	* INSTALL: Document the new configuration options.
	* config.xml-gnome: Add new configuration options to example file.
	* lib/config.php: Add new config option. Olav: rewrite it to avoid
	repeating the same code plus convert to PHP5 class.
	* lib/util.php: Add send_mail function. Olav: slightly modified to
	avoid repeating the same code and only to set the mail params which
	have been set in the config.
	* lib/user.php: Make use of send_mail function.
	* www/list_foundationmembers.php: Make use of send_mail function.
	* www/new_foundationmember.php: Make use of send_mail function.
	* www/update_foundationmember.php: Make use of send_mail function.
	* lib/account.php: Pass account_email config option to the templates.
	Make use of send_mail function.
	* templates/authtoken_mail_verification.xsl: Use account_email.
	* templates/inform_accounts.xsl: Use account_email.
	* templates/maintainer_approval.xsl: Use account_email.
	* templates/requestor_status_change.xsl: Use account_email.



Modified:
   trunk/ChangeLog
   trunk/INSTALL
   trunk/config.xml-gnome
   trunk/lib/account.php
   trunk/lib/config.php
   trunk/lib/user.php
   trunk/lib/util.php
   trunk/templates/authtoken_mail_verification.xsl
   trunk/templates/inform_accounts.xsl
   trunk/templates/maintainer_approval.xsl
   trunk/templates/requestor_status_change.xsl
   trunk/www/list_foundationmembers.php
   trunk/www/new_foundationmember.php
   trunk/www/update_foundationmember.php

Modified: trunk/INSTALL
==============================================================================
--- trunk/INSTALL	(original)
+++ trunk/INSTALL	Sun Jun  1 10:32:10 2008
@@ -171,7 +171,19 @@
 * accounts_db_url, mirrors_db_url and membership_db_url is the url
   of your MySQl server (see step 7). The syntax is as follows:
   mysql://user:password hostname:port/database
-* smtp_url is the url of your smtp server
+* mail_backend chooses the mail backend to use (either sendmail or smtp)
+* mail_sendmail_path is the path to sendmail, if sendmail backend is used
+* mail_sendmail_args are additional arguments for sendmail (sendmail backend)
+* mail_smtp_host is the SMTP server hostname (smtp backend)
+* mail_smtp_port is the SMTP server port (smtp backend)
+* mail_smtp_auth specifies whether or not to use SMTP authentication,
+  use 0 for false and 1 for true (smtp backend)
+* mail_smtp_username is the username to use for SMTP authentication (smtp backend)
+* mail_smtp_password is the password to use for SMTP authentication (smtp backend)
+* mail_smtp_localhost is the value to give when sending EHLO or HELO (smtp backend)
+* mail_smtp_timeout is a timeout for the SMTP connection (smtp backend)
+* mail_smtp_persist specifies whether or not to use persistent SMTP connections,
+  use 0 for false and 1 for true (smtp backend)
 * ldap_url is the url of your ldap server
 * ldap_binddn is your ldap root account (see step 4)
 * ldap_bindpw is the password of your ldap root account (see step 4)
@@ -179,9 +191,9 @@
   user, groups and module data is stored in your ldap directory (see step 5)
 * no idea what token_salt is, probably some kind of salt ;)
 * support_email is the email address of your support team (probably your own)
+* account_email is the email address of those who handle account management
 * session_path is the path where sessions should be stored (see step 3)
 
-
 11.) Connect to http://mango.gnome.local/ (or whatever you set it up to be)
 and off you go. If everything worked, you should be able to login using the
 example user you created earlier in step 6.

Modified: trunk/config.xml-gnome
==============================================================================
--- trunk/config.xml-gnome	(original)
+++ trunk/config.xml-gnome	Sun Jun  1 10:32:10 2008
@@ -6,7 +6,30 @@
   <accounts_db_url>mysql://gnome:gnome localhost localdomain:3306/gnome</accounts_db_url>
   <mirrors_db_url>mysql://gnome:gnome localhost localdomain:3306/gnome</mirrors_db_url>
   <membership_db_url>mysql://gnome:gnome localhost localdomain:3306/gnome</membership_db_url>
-  <smtp_url>smtp://localhost/</smtp_url>
+
+  <!-- Mail backend (either sendmail or smtp) -->
+  <mail_backend>smtp</mail_backend>
+  <!-- Path to sendmail (sendmail backend) -->
+  <mail_sendmail_path>/usr/bin/sendmail</mail_sendmail_path>
+  <!-- Additional options for sendmail (sendmail backend) -->
+  <mail_sendmail_args>-i</mail_sendmail_args>
+  <!-- SMTP server hostname (smtp backend) -->
+  <mail_smtp_host>localhost</mail_smtp_host>
+  <!-- SMTP server port (smtp backend) -->
+  <mail_smtp_port>25</mail_smtp_port>
+  <!-- Whether or not to use SMTP authentication (smtp backend) -->
+  <mail_smtp_auth>0</mail_smtp_auth>
+  <!-- Username to use for SMTP authentication (smtp backend) -->
+  <mail_smtp_username>johndoe</mail_smtp_username>
+  <!-- Password to use for SMTP authentication (smtp backend) -->
+  <mail_smtp_password>nottelling</mail_smtp_password>
+  <!-- Value to give when sending EHLO or HELO (smtp backend) -->
+  <mail_smtp_localhost>mango.gnome.org</mail_smtp_localhost>
+  <!-- SMTP connection timeout (smtp backend) -->
+  <mail_smtp_timeout>30</mail_smtp_timeout>
+  <!-- Whether or not to use persistent SMTP connections (smtp backend) -->
+  <mail_smtp_persist>0</mail_smtp_persist>  
+
   <ldap_url>ldap://localhost/</ldap_url>
   <ldap_binddn>cn=Manager,dc=gnome,dc=org</ldap_binddn>
   <ldap_bindpw>nottelling</ldap_bindpw>
@@ -16,5 +39,9 @@
   <ldap_modules_basedn>ou=modules,dc=gnome,dc=org</ldap_modules_basedn>
   <token_salt>nottelling</token_salt>
   <support_email>rossg gnome org</support_email>
+
+  <!-- Email address of person(s) who handles account management -->
+  <account_email>accounts gnome org</account_email>  
+  
   <session_path>/var/lib/mango/sessions</session_path>
 </config>

Modified: trunk/lib/account.php
==============================================================================
--- trunk/lib/account.php	(original)
+++ trunk/lib/account.php	Sun Jun  1 10:32:10 2008
@@ -2,8 +2,6 @@
 
 require_once("mysql.php");
     
-require_once("Mail.php");
-require_once("Mail/mime.php");
 require_once("module.php");
 require_once("util.php");
 
@@ -424,7 +422,8 @@
         $mailnode->setAttribute("baseurl", $config->base_url);
         $usernode = $mailnode->appendChild($maildom->createElement("account"));
         $this->add_to_node($maildom, $usernode);
-        
+        $supportnode = $mailnode->appendChild($maildom->createElement('account_email'));
+        $supportnode->appendChild($maildom->createTextNode($config->account_email));
         if (!is_null($extra_mailnodes)) {
             foreach ($extra_mailnodes as $key=>$value) {
                 $items = is_array($value) ? $value : array($value);
@@ -448,29 +447,15 @@
     function _send_email($mailbody, $to, $subject) {
         global $config;
 
-        $mime = new Mail_Mime();
         $headers = array(
-                "Reply-To" => "Mango <accounts gnome org>",
-                "From" => "Mango <accounts gnome org>",
-                "To" => $to,
-                "Subject" => $subject,
-        );
-        $params = array(
-                'head_charset' => 'UTF-8',
-                'head_encoding' => 'quoted-printable',
-                'text_charset' => 'UTF-8',
+            'Reply-To' => '<'.$config->account_email.'>',
+            'From' => 'Mango <'.$config->account_email.'>',
+            'To' => '<'.$to.'>',
+            'Subject' => $subject,
+
         );
-        $mime->setTXTBody($mailbody);
-        $content = $mime->get($params);
-        $headers = $mime->headers($headers);
-        $mail = &Mail::factory('smtp');
-
-        // DEBUG: Send to support address for debugging purposes
-        if ($config->mode != 'live')
-            $to = $config->support_email;
 
-        $error = $mail->send($to, $headers, $content);
-        return $error;
+        return send_mail($to, $subject, $headers, $mailbody);
     }
 
     function fill_user($user) {

Modified: trunk/lib/config.php
==============================================================================
--- trunk/lib/config.php	(original)
+++ trunk/lib/config.php	Sun Jun  1 10:32:10 2008
@@ -8,66 +8,49 @@
  * Site-wide configuration object
  */
 class SiteConfig {
-	// Date config last read from disk
-	var $cached_date;
-
-	// Runtime mode (Live/Preview/Development)
-	var $mode;
-
-	// Base URL
-	var $base_url;
-
-	// Mirrors MySQL database URL
-	var $accounts_db_url;
-	
-	// Mirrors MySQL database URL
-	var $mirrors_db_url;
-
-	// Foundation membership MySQL database URL
-	var $membership_db_url;
-
-	// SMTP URL
-	var $smtp_url;
-
-	// LDAP URL
-	var $ldap_url;
-
-	// LDAP bind DN
-	var $ldap_binddn;
-
-	// LDAP bind PW
-	var $ldap_bindpw;
-
-	// LDAP base DN
-	var $ldap_basedn;
-
-	// LDAP users base DN
-	var $ldap_users_basedn;
-
-	// LDAP groups base DN
-	var $ldap_groups_basedn;
-
-	// LDAP modules base DN
-	var $ldap_modules_basedn;
-	
-	// LDAP aliases base DN
-	var $ldap_aliases_basedn;
-
-	// Salt to be used in e-mail tokens
-	var $token_salt;
-	
-	// Support e-mail
-	var $support_email;
-
-	// Session save path
-	var $session_path;
-
-	/*
-	 * Constructor. Modify configuration stuff here.
-	 */
-	function SiteConfig() {
-		$this->cached_date = time();
-	}
+    public
+        $cached_date,       // Date config last read from disk
+        $mode,              // Runtime mode (Live/Preview/Development)
+        $base_url,          // Base URL
+
+        $accounts_db_url,   // Mirrors MySQL database URL
+        $mirrors_db_url,    // Mirrors MySQL database URL
+        $membership_db_url, // Foundation membership MySQL database URL
+
+        $mail_backend,       // Mail backend
+        $mail_sendmail_path, // Path to sendmail (sendmail backend)
+        $mail_sendmail_args, // Additional options for sendmail (sendmail backend)
+        $mail_smtp_host,     // SMTP server hostname (smtp backend)
+        $mail_smtp_port,     // SMTP server port (smtp backend)
+        $mail_smtp_auth,     // Whether or not to use smtp authentication (smtp backend)
+        $mail_smtp_username, // Username to use for SMTP authentication (smtp backend)
+        $mail_smtp_password, // Password to use for SMTP authentication (smtp backend)
+        $mail_smtp_localhost, // Value to give when sending EHLO or HELO (smtp backend)
+        $mail_smtp_timeout,  // SMTP connection timeout
+        $mail_smtp_persist,  // Whether or not to use persistent SMTP connections (smtp backend)
+
+        $ldap_url,            // LDAP URL
+        $ldap_binddn,         // LDAP bind DN
+        $ldap_bindpw,         // LDAP bind PW
+        $ldap_basedn,         // LDAP base DN
+        $ldap_users_basedn,   // LDAP users base DN
+        $ldap_groups_basedn,  // LDAP groups base DN
+        $ldap_modules_basedn, // LDAP modules base DN
+        $ldap_aliases_basedn, // LDAP aliases base DN
+
+        $token_salt,          // Salt to be used in e-mail tokens
+
+        $support_email,       // Support e-mail
+        $account_email,       // Email address of person(s) who handles account management -->
+
+        $session_path;        // Session save path
+
+    /*
+     * Constructor. Modify configuration stuff here.
+     */
+    function __construct() {
+        $this->cached_date = time();
+    }
 
 	/*
 	 * Read from the configuration file
@@ -101,87 +84,30 @@
                 return true;
 	}
 
-	/*
-	 * Read configuration from given node
-	 */
-	function read_from($node) {
-		$children = $node->childNodes;
-		
-		// Running mode
-		if($node->nodeType == XML_ELEMENT_NODE && $node->tagName == "mode")
-			$this->mode = $children->item(0)->textContent;
-
-		// Base URL
-		if($node->nodeType == XML_ELEMENT_NODE && $node->tagName == "base_url")
-			$this->base_url = $children->item(0)->textContent;
-
-		// Accounts database URL
-		if($node->nodeType == XML_ELEMENT_NODE && $node->tagName == "accounts_db_url")
-			$this->accounts_db_url = $children->item(0)->textContent;
-			
-		// Mirors database URL
-		if($node->nodeType == XML_ELEMENT_NODE && $node->tagName == "mirrors_db_url")
-			$this->mirrors_db_url = $children->item(0)->textContent;
-
-		// Membership database URL
-		if($node->nodeType == XML_ELEMENT_NODE && $node->tagName == "membership_db_url")
-			$this->membership_db_url= $children->item(0)->textContent;
-
-		// SMTP e-mail server information
-		if($node->nodeType == XML_ELEMENT_NODE && $node->tagName == "smtp_url")
-			$this->smtp_url = $children->item(0)->textContent;
-
-		// LDAP server URL
-		if($node->nodeType == XML_ELEMENT_NODE && $node->tagName == "ldap_url")
-			$this->ldap_url = $children->item(0)->textContent;
-
-		// LDAP bind DN
-		if($node->nodeType == XML_ELEMENT_NODE && $node->tagName == "ldap_binddn")
-			$this->ldap_binddn = $children->item(0)->textContent;
-
-		// LDAP bind password
-		if($node->nodeType == XML_ELEMENT_NODE && $node->tagName == "ldap_bindpw")
-			$this->ldap_bindpw = $children->item(0)->textContent;
-
-		// LDAP base DN
-		if($node->nodeType == XML_ELEMENT_NODE && $node->tagName == "ldap_basedn")
-			$this->ldap_basedn = $children->item(0)->textContent;
-
-		// LDAP users base DN
-		if($node->nodeType == XML_ELEMENT_NODE && $node->tagName == "ldap_users_basedn")
-			$this->ldap_users_basedn = $children->item(0)->textContent;
-
-		// LDAP groups base DN
-		if($node->nodeType == XML_ELEMENT_NODE && $node->tagName == "ldap_groups_basedn")
-			$this->ldap_groups_basedn = $children->item(0)->textContent;
-
-		// LDAP modules base DN
-		if($node->nodeType == XML_ELEMENT_NODE && $node->tagName == "ldap_modules_basedn")
-			$this->ldap_modules_basedn = $children->item(0)->textContent;
-
-		// LDAP aliases base DN
-		if($node->nodeType == XML_ELEMENT_NODE && $node->tagName == "ldap_aliases_basedn")
-			$this->ldap_aliases_basedn = $children->item(0)->textContent;
-				
-		// Token salt
-		if($node->nodeType == XML_ELEMENT_NODE && $node->tagName == "token_salt")
-			$this->token_salt = $children->item(0)->textContent;
-				
-		// Support e-mail
-		if($node->nodeType == XML_ELEMENT_NODE && $node->tagName == "support_email")
-			$this->support_email = $children->item(0)->textContent;
-
-		// Session save path
-		if($node->nodeType == XML_ELEMENT_NODE && $node->tagName == "session_path")
-			$this->session_path = $children->item(0)->textContent;
-	}
+    /*
+     * Read configuration from given node
+     */
+    function read_from($node) {
+        $children = $node->childNodes;
+
+        if ($node->nodeType == XML_ELEMENT_NODE) {
+            $tagname = $node->tagName;
+
+            if (property_exists($this, $tagname))
+                $this->$tagname = $children->item(0)->textContent;
+        }
+
+        foreach (array('mail_smtp_auth', 'mail_smtp_persist') as $tagname)
+            $this->$tagname = (boolean) $this->$tagname;
+
+    }
 }
 
 // Set global config variable
 $config = new SiteConfig();
 $result = $config->read();
 if(PEAR::isError($result)) {
-	exit("Error: ".$result->getMessage());
+    exit("Error: ".$result->getMessage());
 }
 
 // Set session save path

Modified: trunk/lib/user.php
==============================================================================
--- trunk/lib/user.php	(original)
+++ trunk/lib/user.php	Sun Jun  1 10:32:10 2008
@@ -371,26 +371,15 @@
                'Your new GNOME account' :
                'Changes to your GNOME account';
 
-        $mime = new Mail_Mime();
-        $mime->setTXTBody($body);
+        $to = $this->mail;
         $headers = array(
-            "Reply-To" => "Mango <accounts gnome org>",
-            "From" => "Mango <accounts gnome org>",
-            "To" => $this->mail,
-            "Subject" => $subject,
+            'Reply-To' => '<'.$config->account_email.'>',
+            'From' => 'Mango <'.$config->account_email.'>',
+            'To' => '<'.$to.'>',
+            'Subject' => $subject
         );
-        $params = array(
-            'head_charset' => 'UTF-8',
-            'head_encoding' => 'quoted-printable',
-            'text_charset' => 'UTF-8',
-        );
-        $content = $mime->get($params);
-        $headers = $mime->headers($headers);
-        $mail = &Mail::factory('smtp');
-        $recipient = ($config->mode == 'live') ? $this->mail : $config->support_email;
-        $error = $mail->send($recipient, $headers, $content);
 
-        return $error;
+        return send_mail($to, $subject, $headers, $body);
     }
 
     function _next_uidnumber(&$ldap) {

Modified: trunk/lib/util.php
==============================================================================
--- trunk/lib/util.php	(original)
+++ trunk/lib/util.php	Sun Jun  1 10:32:10 2008
@@ -1,5 +1,8 @@
 <?
 
+require_once('Mail.php');
+require_once('Mail/mime.php');
+
 function is_valid_ssh_pub_key($key, $check_length = True, $return_fingerprint = false) {
     if(empty($key) || substr($key, 0, 4) != "ssh-")
         return false;
@@ -42,4 +45,47 @@
 
 }
 
+function send_mail($recipients, $subject, $headers, $body) {
+    global $config;
+    
+    $mime = new Mail_Mime();
+    $mime->setTXTBody($body);
+    $mime_params = array(
+        'head_charset' => 'UTF-8',
+        'head_encoding' => 'quoted-printable',
+        'text_charset' => 'UTF-8'
+    );
+    $content = $mime->get($mime_params);
+    $headers = $mime->headers($headers);
+
+
+    $cfg_sendmails = array('sendmail_path', 'sendmail_args');
+    $cfg_smtps = array('host', 'port', 'auth', 'username', 'password', 'localhost',
+                       'timeout', 'persist');
+
+    $cfgprefix = $config->mail_backend == 'smtp' ? 'mail_smtp_' : 'mail_';
+    $cfgopts = $config->mail_backend == 'smtp' ? $cfg_smtps : $cfg_sendmails;
+
+    foreach ($cfgopts as $opt) {
+        $cfgopt = $cfgprefix . $opt;
+        if (!empty($config->$cfgopt))
+            $mail_params[$opt] = $config->$cfgopt;
+    }
+
+    // DEVELOPMENT mode
+    if ($config->mode == 'development') {
+        // Always send mail to support address
+        $recipients = $config->support_email;
+
+        // Enable SMTP debug mode
+        // if ($config->mail_backend == 'smtp') {
+        //   $mail_params['debug'] = true;
+        // }
+    }
+
+    // Send mail
+    $mail = &Mail::factory($config->mail_backend, $mail_params);
+    return $mail->send($recipients, $headers, $content);
+}
+
 ?>

Modified: trunk/templates/authtoken_mail_verification.xsl
==============================================================================
--- trunk/templates/authtoken_mail_verification.xsl	(original)
+++ trunk/templates/authtoken_mail_verification.xsl	Sun Jun  1 10:32:10 2008
@@ -24,5 +24,5 @@
 can send your questions to the accounts team e-mail address.
 -- 
 The GNOME Accounts Team
-&lt;accounts gnome org&gt;</xsl:template>   
+&lt;<xsl:value-of select="account_email"/>&gt;</xsl:template>   
 </xsl:stylesheet>

Modified: trunk/templates/inform_accounts.xsl
==============================================================================
--- trunk/templates/inform_accounts.xsl	(original)
+++ trunk/templates/inform_accounts.xsl	Sun Jun  1 10:32:10 2008
@@ -28,5 +28,5 @@
 can send your questions to the accounts team e-mail address.
 -- 
 The GNOME Accounts Team
-&lt;accounts gnome org&gt;</xsl:template>   
+&lt;<xsl:value-of select="account_email"/>&gt;</xsl:template>   
 </xsl:stylesheet>

Modified: trunk/templates/maintainer_approval.xsl
==============================================================================
--- trunk/templates/maintainer_approval.xsl	(original)
+++ trunk/templates/maintainer_approval.xsl	Sun Jun  1 10:32:10 2008
@@ -52,6 +52,6 @@
 can send your questions to the accounts team e-mail address. 
 -- 
 The GNOME Accounts Team
-&lt;accounts gnome org&gt;
+&lt;<xsl:value-of select="account_email"/>&gt;
   </xsl:template>   
 </xsl:stylesheet>

Modified: trunk/templates/requestor_status_change.xsl
==============================================================================
--- trunk/templates/requestor_status_change.xsl	(original)
+++ trunk/templates/requestor_status_change.xsl	Sun Jun  1 10:32:10 2008
@@ -28,5 +28,5 @@
 can send your questions to the accounts team e-mail address.
 -- 
 The GNOME Accounts Team
-&lt;accounts gnome org&gt;</xsl:template>   
+&lt;<xsl:value-of select="account_email"/>&gt;</xsl:template>   
 </xsl:stylesheet>

Modified: trunk/www/list_foundationmembers.php
==============================================================================
--- trunk/www/list_foundationmembers.php	(original)
+++ trunk/www/list_foundationmembers.php	Sun Jun  1 10:32:10 2008
@@ -4,6 +4,7 @@
 require_once("../lib/page.php");
 require_once("../lib/paged_results.php");
 require_once("../lib/foundationmember.php");
+require_once('../lib/util.php');
 
 define('STYLESHEET', 'list_foundationmembers.xsl');
 define('SESSIONID', 'list_foundationmembers');
@@ -150,25 +151,15 @@
                     // Replacing member name to template-mail body
                     $body = str_replace('<member>', $membername, $body);
                     $recipients = array ($to, $cc);
-                    $mime = new Mail_Mime();
-                    $mime->setTXTBody($body);
                     $headers = array(
-                    "Reply-To" => "<membership-committee gnome org>",
-                    "From" => "GNOME Foundation Membership Committee <membership-committee gnome org>",
-                    "To" => $to,
-                    "Cc" => $cc,
-                    "Subject" => $subject,
+                        'Reply-To' => '<membership-committee gnome org>',
+                        'From' => 'GNOME Foundation Membership Committee <membership-committee gnome org>',
+                        'To' => $membername.' <'.$to.'>',
+                        'Cc' => '<'.$cc.'>',
+                        'Subject' => $subject
                     );
-                    $params = array(
-                        'head_charset' => 'UTF-8',
-                        'head_encoding' => 'quoted-printable',
-                        'text_charset' => 'UTF-8',
-                    );
-                    $content = $mime->get($params);
-                    $headers = $mime->headers($headers);
-                    $mail = &Mail::factory('smtp');
-                    $error = $mail->send($recipients, $headers, $content);
-
+                    $error = send_mail($recipients, $subject, $headers, $body);
+                    
                     if(PEAR::isError($error))
                         return $error;
                     

Modified: trunk/www/new_foundationmember.php
==============================================================================
--- trunk/www/new_foundationmember.php	(original)
+++ trunk/www/new_foundationmember.php	Sun Jun  1 10:32:10 2008
@@ -3,6 +3,7 @@
 
 require_once("../lib/page.php");
 require_once("../lib/foundationmember.php");
+require_once('../lib/util.php');
 
 define('STYLESHEET', 'new_foundationmember.xsl');
 define('SESSIONID', 'new_foundationmember');
@@ -88,24 +89,14 @@
             // Replacing member name to template-mail body
             $body = str_replace('<member>', $membername, $body);
             $recipients = array ($to, $cc);
-            $mime = new Mail_Mime();
-            $mime->setTXTBody($body);
             $headers = array(
-                "Reply-To" => "<membership-committee gnome org>",
-                "From" => "GNOME Foundation Membership Committee <membership-committee gnome org>",
-                "To" => $to,
-                "Cc" => $cc,
-                "Subject" => $subject,
+                'Reply-To' => '<membership-committee gnome org>',
+                'From' => 'GNOME Foundation Membership Committee <membership-committee gnome org>',
+                'To' => $membername.' <'.$to.'>',
+                'Cc' => '<'.$cc.'>',
+                'Subject' => $subject
             );
-            $params = array(
-                'head_charset' => 'UTF-8',
-                'head_encoding' => 'quoted-printable',
-                'text_charset' => 'UTF-8',
-            );
-            $content = $mime->get($params);
-            $headers = $mime->headers($headers);
-            $mail = &Mail::factory('smtp');
-            $error = $mail->send($recipients, $headers, $content);
+            $error = send_mail($recipients, $subject, $headers, $body);
             if(PEAR::isError($error))
                 return $error;
 

Modified: trunk/www/update_foundationmember.php
==============================================================================
--- trunk/www/update_foundationmember.php	(original)
+++ trunk/www/update_foundationmember.php	Sun Jun  1 10:32:10 2008
@@ -3,6 +3,7 @@
 
 require_once("../lib/page.php");
 require_once("../lib/foundationmember.php");
+require_once('../lib/util.php');
 
 define('STYLESHEET', 'update_foundationmember.xsl');
 define('SESSIONID', 'update_foundationmember');
@@ -116,24 +117,14 @@
                 // Replacing member name to template-mail body
                 $body = str_replace('<member>', $membername, $body);
                 $recipients = array ($to, $cc);
-                $mime = new Mail_Mime();
-                $mime->setTXTBody($body);
                 $headers = array(
-                    "Reply-To" => "<membership-committee gnome org>",
-                    "From" => "GNOME Foundation Membership Committee <membership-committee gnome org>",
-                    "To" => $to,
-                    "Cc" => $cc,
-                    "Subject" => $subject,
+                    'Reply-To' => '<membership-committee gnome org>',
+                    'From' => 'GNOME Foundation Membership Committee <membership-committee gnome org>',
+                    'To' => $membername.' <'.$to.'>',
+                    'Cc' => '<'.$cc.'>',
+                    'Subject' => $subject
                 );
-                $params = array(
-                    'head_charset' => 'UTF-8',
-                    'head_encoding' => 'quoted-printable',
-                    'text_charset' => 'UTF-8',
-                );
-                $content = $mime->get($params);
-                $headers = $mime->headers($headers);
-                $mail = &Mail::factory('smtp');
-                $error = $mail->send($recipients, $headers, $content);
+                $error = send_mail($recipients, $subject, $headers, $body);
                 if(PEAR::isError($error))
                     return $error;
                 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]