Index: config-kmail.h.cmake
===================================================================
--- config-kmail.h.cmake	(revision 771626)
+++ config-kmail.h.cmake	(working copy)
@@ -10,3 +10,7 @@
 #cmakedefine HAVE_SYS_INOTIFY_H 1
 
 #cmakedefine Nepomuk_FOUND 1
+
+#define KMAIL_SVN_REVISION_STRING "@kmail_svn_revision@"
+
+#define KMAIL_SVN_LAST_CHANGE "@kmail_svn_last_change@"
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt	(revision 771626)
+++ CMakeLists.txt	(working copy)
@@ -8,6 +8,17 @@
 check_include_files(sys/inotify.h SYS_INOTIFY_H_FOUND)
 macro_bool_to_01(SYS_INOTIFY_H_FOUND HAVE_SYS_INOTIFY_H)
 
+if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.svn")
+  if ( NOT KdeSubversion_FOUND )
+    find_package( KdeSubversion )
+  endif ( NOT KdeSubversion_FOUND )
+  if ( KdeSubversion_FOUND )
+    KdeSubversion_WC_INFO( ${PROJECT_SOURCE_DIR} KMail )
+    string( SUBSTRING "${KMail_WC_LAST_CHANGED_DATE}" 0 10 KMail_WC_LAST_CHANGED_DATE )
+    set( kmail_svn_revision "svn-${KMail_WC_REVISION}" )
+    set( kmail_svn_last_change "${KMail_WC_LAST_CHANGED_DATE}" )
+  endif ( KdeSubversion_FOUND )
+endif (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.svn")
 configure_file(config-kmail.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kmail.h )
 
 add_definitions (-DQT3_SUPPORT -DQT3_SUPPORT_WARNINGS)
Index: kmmessage.cpp
===================================================================
--- kmmessage.cpp	(revision 771626)
+++ kmmessage.cpp	(working copy)
@@ -17,6 +17,7 @@
 #include "kmfolderindex.h"
 #include "undostack.h"
 #include "kmversion.h"
+#include "config-kmail.h"
 #include "kmmessagetag.h"
 #include "headerstrategy.h"
 #include "globalsettings.h"
@@ -43,6 +44,7 @@
 #include <kuser.h>
 #include <k3resolver.h>
 #include <kconfiggroup.h>
+#include <KProtocolManager>
 
 #include <QList>
 #include <QCursor>
@@ -1688,7 +1690,15 @@
   setSubject("");
   setDateToday();
 
-  setHeaderField("User-Agent", "KMail/" KMAIL_VERSION );
+  // user agent, e.g. KMail/1.9.50 (Windows/5.0; KDE/3.97.1; i686; svn-762186; 2008-01-15)
+  QStringList extraInfo;
+#if defined KMAIL_SVN_REVISION_STRING && defined KMAIL_SVN_LAST_CHANGE
+  extraInfo << KMAIL_SVN_REVISION_STRING << KMAIL_SVN_LAST_CHANGE;
+#endif
+  setHeaderField("User-Agent", 
+    KProtocolManager::userAgentForApplication( "KMail", KMAIL_VERSION, extraInfo )
+  );
+
   // This will allow to change Content-Type:
   setHeaderField("Content-Type","text/plain");
 }
