--- /video/phpgroupware/email/inc/class.mail_send.inc.php	2009-02-21 13:03:05.000000000 +0100
+++ /usr/share/phpgroupware/email/inc/class.mail_send.inc.php	2009-03-06 17:03:11.000000000 +0100
@@ -206,10 +206,49 @@
 // lets assume for the purpose of testing that these variables were already set up somewhere.
 // That still needs to be done properly.
 // angles: this is a temp handler until it gets in the email site setup page as site option
-$smtp_auth_login_required = False;
-//$smtp_auth_login_required = true;
-$mylogin = "xxxxxx";
-$mypassword = "xxxxxxxxxx";
+
+// To use SMTP authentication use $smtp_auth_login_required = true
+//$smtp_auth_login_required = False;
+$smtp_auth_login_required = true;
+
+// START CHANGES gfwp@ticino.com March 2009
+//To have a static single account logging for all the users fill the corresponding variables here and uncomment the following
+//the followingthree lines; otherwise set $dynamic_smpt_login = true (uncomment it) so the login and passwd are taken
+//from phpgwapi
+//$mylogin = "";
+//$mypassword = "";
+//$dynamic_smtp_login = False;
+$dynamic_smpt_login = true;
+
+	function decrypt_email_passwd($data)
+	{
+		$cryptovars[0] = md5($GLOBALS['phpgw_info']['server']['encryptkey']);
+		$cryptovars[1] = $GLOBALS['phpgw_info']['server']['mcrypt_iv'];
+		$crypto = CreateObject('phpgwapi.crypto',$cryptovars);
+		$unencrypted = $crypto->decrypt($data);
+		return $unencrypted;
+	};
+
+	if($dynamic_smpt_login)
+	{
+			//To use user preference email settings
+		if ( (isset($GLOBALS['phpgw_info']['user']['preferences']['email']['userid']))
+			&& ($GLOBALS['phpgw_info']['user']['preferences']['email']['userid'] != '')
+			&& (isset($GLOBALS['phpgw_info']['user']['preferences']['email']['passwd']))
+			&& ($GLOBALS['phpgw_info']['user']['preferences']['email']['passwd'] != '') )
+		{
+			//Assumes that in the preferences the account name is written with mail domain user@mymail.com
+			$mylogin = $GLOBALS['phpgw_info']['user']['preferences']['email']['userid'];
+			$mypassword = $GLOBALS['phpgw_info']['user']['preferences']['email']['passwd'];
+		}else
+		{
+			//To use default login email settings
+			$mylogin = $GLOBALS['phpgw_info']['user']['userid'] . '@' . $GLOBALS['phpgw_info']['server']['mail_suffix'];
+			$mypassword = decrypt_email_passwd($GLOBALS['phpgw_info']['user']['passwd']);
+		}
+	}
+
+//END CHANGES gfwp@ticino.com
 
 			if ($smtp_auth_login_required)
 			{
