--- SoObjects/SOGo/SOGoMailer.m.orig	2024-10-15 14:26:45 UTC
+++ SoObjects/SOGo/SOGoMailer.m
@@ -35,6 +35,7 @@
 #import "SOGoUser.h"
 #import "SOGoUserManager.h"
 #import "SOGoMailer.h"
+#import "SOGoCASSession.h"
 
 //
 // Useful extension that comes from Pantomime which is also
@@ -265,7 +266,7 @@ - (NSException *) _smtpSendData: (NSData *) mailData
                       inContext: (WOContext *) woContext
                   systemMessage: (BOOL) isSystemMessage
 {
-  NSString *currentTo, *login, *password;
+  NSString *currentTo, *login, *password, *service, *scheme, *serverhost, *authType;
   NSDictionary *currentAcount;
   NSMutableArray *toErrors;
   NSEnumerator *addresses;
@@ -273,6 +274,8 @@ - (NSException *) _smtpSendData: (NSData *) mailData
   NSException *result;
   NSURL * smtpUrl;
   SOGoUser* user;
+  SOGoSystemDefaults *sd;
+  SOGoCASSession *session;
   BOOL doSmtpAuth;
 
   result = nil;
@@ -315,7 +318,22 @@ - (NSException *) _smtpSendData: (NSData *) mailData
                         getExternalLoginForUID: [[authenticator userInContext: woContext] loginInDomain]
                                       inDomain: [[authenticator userInContext: woContext] domain]];
 
+            sd = [SOGoSystemDefaults sharedSystemDefaults];
+            authType = [sd authenticationType];
             password = [authenticator passwordInContext: woContext];
+            if ([authType isEqualToString: @"cas"])
+              {
+                // hardcoded scheme
+                // scheme = @"imap";
+                // serverhost = @"sogo"; 
+                // service = [NSString stringWithFormat: @"%@://%@", scheme, serverhost];
+                session = [SOGoCASSession CASSessionWithIdentifier: password
+                                                         fromProxy: NO];
+                service = @"imap://sogo";
+                password = [session ticketForService: service];
+                if ([password length])
+                  [session updateCache];
+              }
           }
 
 
