[evolution] Bug 585577 - Wrong FROM in envelope during SMTP negotiation



commit a52f00a9c9c00ecf06ac7179742ceb15e9971c5d
Author: Fabien Tassin <fta+bugzilla sofaraway org>
Date:   Fri May 28 23:17:58 2010 -0400

    Bug 585577 - Wrong FROM in envelope during SMTP negotiation

 mail/mail-ops.c |   38 ++++++++++++++++++++++++++++++++++++--
 1 files changed, 36 insertions(+), 2 deletions(-)
---
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index 128cb28..e3ab0d5 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -515,8 +515,42 @@ mail_send_message (struct _send_queue_msg *m, CamelFolder *queue, const gchar *u
 	if (resent_from) {
 		camel_address_decode (from, resent_from);
 	} else {
-		iaddr = camel_mime_message_get_from (message);
-		camel_address_copy (from, CAMEL_ADDRESS (iaddr));
+		/* Don't get the 'from' from the headers */
+		/* See https://bugzilla.gnome.org/show_bug.cgi?id=585577 */
+		gchar *fake_msgid;
+		gchar *hostname;
+		EAccount *account;
+		gchar *address;
+		gchar *cp;
+
+		/* We use camel_header_msgid_generate () to get a canonical
+		 * hostname, then skip the part leading to '@' */
+		fake_msgid = camel_header_msgid_generate ();
+		hostname = strchr (fake_msgid, '@');
+		hostname++;
+
+		/* wfm but it should probably be getpwent->pw_name instead */
+		account = e_get_default_account ();
+		if (!account) {
+			/* XXX Not sure what we should do here. */
+			address = g_strdup ("fakename");
+		} else {
+			address = g_strdup (
+				e_account_get_string (
+				account, E_ACCOUNT_ID_ADDRESS));
+			cp = strchr (address, '@');
+			if (cp != NULL)
+				*cp = '\0';
+		}
+
+		cp = g_strconcat (address, "@", hostname, NULL);
+		g_free (address);
+		address = cp;
+
+		camel_address_decode (from, address);
+
+		g_free (fake_msgid);
+		g_free (address);
 	}
 
 	recipients = (CamelAddress *) camel_internet_address_new ();



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