diff -up msmtp-1.4.16/configure.ac.gk msmtp-1.4.16/configure.ac
--- msmtp-1.4.16/configure.ac.gk	2008-07-28 07:39:34.000000000 +0900
+++ msmtp-1.4.16/configure.ac	2008-08-28 00:25:59.000000000 +0900
@@ -181,6 +181,19 @@ if test "$libidn" != "no"; then
     fi
 fi
 
+dnl gnome-keyring support (requires pkg-config).
+AC_ARG_WITH([gnome-keyring],
+    [AC_HELP_STRING([--with-gnome-keyring],[Support GNOME Keyring])],
+    [gnome_keyring=$withval],[gnome_keyring=no])
+if test "$gnome_keyring" != "no"; then
+    PKG_CHECK_MODULES([GNOMEKEYRING],[gnome-keyring-1],[
+        CFLAGS="$CFLAGS $GNOMEKEYRING_CFLAGS"
+        LIBS="$LIBS $GNOMEKEYRING_LIBS"
+        AC_DEFINE([HAVE_GNOMEKEYRING],[1],
+            [Define to 1 if you have GNOME Keyring API.])
+        ],[AC_MSG_WARN([Cannot find GNOME Keyring API, disabling])])
+fi
+
 dnl MacOS X Keychain Services (Security Framework)
 AC_CACHE_CHECK([for SecKeychainGetVersion],
     ac_cv_func_SecKeychainGetVersion,
@@ -230,3 +243,4 @@ echo "TLS/SSL support ...... : $have_tls
 echo "GNU SASL support ..... : $libgsasl"
 echo "GNU Libidn support ... : $libidn"
 echo "NLS support .......... : $USE_NLS"
+echo "GNOME Keyring support  : $gnome_keyring"
diff -up msmtp-1.4.16/src/msmtp.c.gk msmtp-1.4.16/src/msmtp.c
--- msmtp-1.4.16/src/msmtp.c.gk	2008-06-03 09:02:26.000000000 +0900
+++ msmtp-1.4.16/src/msmtp.c	2008-08-28 00:24:57.000000000 +0900
@@ -57,6 +57,9 @@ extern int optind;
 #include <netdb.h>
 #include <arpa/inet.h>
 #endif
+#ifdef HAVE_GNOMEKEYRING
+#include <gnome-keyring.h>
+#endif
 #ifdef HAVE_KEYCHAIN
 #include <Security/Security.h>
 #endif
@@ -286,6 +289,11 @@ char *msmtp_password_callback(const char
     char *netrc_filename;
     netrc_entry *netrc_hostlist;
     netrc_entry *netrc_host;
+#ifdef HAVE_GNOMEKEYRING
+    const char *protocol = "smtp";
+    GList *found_list = NULL;
+    GnomeKeyringNetworkPasswordData *found;
+#endif
 #ifdef HAVE_KEYCHAIN
     void *password_data;
     UInt32 password_length;
@@ -310,8 +318,29 @@ char *msmtp_password_callback(const char
     }
     free(netrc_filename);
 
+#ifdef HAVE_GNOMEKEYRING
+    if (!password) {
+        g_set_application_name(PACKAGE);
+        if (gnome_keyring_find_network_password_sync(
+                        user,     /* user */
+                        NULL,     /* domain */
+                        hostname, /* server */
+                        NULL,     /* object */
+                        protocol, /* protocol */
+                        NULL,     /* authtype */
+                        0,        /* port */
+                        &found_list) == GNOME_KEYRING_RESULT_OK)
+        {
+            found = (GnomeKeyringNetworkPasswordData *) found_list->data;
+            if (found->password)
+                password = g_strdup(found->password);
+        }
+        gnome_keyring_network_password_list_free(found_list);
+    }
+#endif /* HAVE_GNOMEKEYRING */
+
 #ifdef HAVE_KEYCHAIN
-    if (SecKeychainFindInternetPassword(
+    if (!password && SecKeychainFindInternetPassword(
 		NULL,
 		strlen(hostname), hostname,
 		0, NULL,

