Update of /cvsroot/mahogany/M/src/mail
In directory usw-pr-cvs1:/tmp/cvs-serv2068/src/mail
Modified Files:
SendMessageCC.cpp
Log Message:
generate the Message-Id header ourselves
Index: SendMessageCC.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/mail/SendMessageCC.cpp,v
retrieving revision 1.190
retrieving revision 1.191
diff -b -u -2 -r1.190 -r1.191
--- SendMessageCC.cpp 12 Jun 2002 17:19:02 -0000 1.190
+++ SendMessageCC.cpp 12 Jun 2002 19:35:50 -0000 1.191
@@ -55,4 +55,9 @@
#include <wx/file.h>
#include <wx/fontmap.h> // for GetEncodingName()
+#include <wx/datetime.h>
+
+#ifdef OS_UNIX
+ #include <unistd.h> // for getpid()
+#endif
extern bool InitSSL(); // from src/util/ssl.cpp
@@ -977,4 +982,48 @@
// ----------------------------------------------------------------------------
+/// build a unique string for the Message-Id header
+static
+String BuildMessageId(const char *hostname)
+{
+ // get the PID from OS (TODO: should have a wxWin function for this)
+ static unsigned long s_pid = 0;
+
+ if ( !s_pid )
+ {
+#ifdef OS_WIN
+ extern "C" DWORD GetCurrentProcessId();
+
+ s_pid = (unsigned long)GetCurrentProcessId();
+#elif defined(OS_UNIX)
+ s_pid = (unsigned long)getpid();
+#else
+ #error "Don't know how to getpid() on this platform"
+#endif
+ }
+
+ // get the time to make the message-id unique and use s_numInSec to make the
+ // messages sent during the same second unique
+ static unsigned int s_numInSec = 0;
+ static wxDateTime s_dtLast;
+
+ wxDateTime dt = wxDateTime::Now();
+ if ( s_dtLast.IsValid() && s_dtLast == dt )
+ {
+ s_numInSec++;
+ }
+ else
+ {
+ s_dtLast = dt;
+ s_numInSec = 0;
+ }
+
+ return String::Format("<Mahogany-%s-%lu-%s.%02u@%s>",
+ M_VERSION,
+ s_pid,
+ dt.Format("%Y%m%d-%H%M%S").c_str(),
+ s_numInSec,
+ hostname);
+}
+
void
SendMessageCC::Build(bool forStorage)
@@ -988,11 +1037,32 @@
m_wasBuilt = true;
- // this must be done for the new as well as resent messages: RFC 2822 says
- // that Resent-From should be always present (section 3.6.6)
+ // the headers needed for all messages
+ // -----------------------------------
+
+ // see section 3.6.6 of RFC 2822 for the full list of headers which must be
+ // present in resent messages
+
+ // From:
SetupFromAddresses();
+ // To:, Cc: and Bcc: have been already set by SetAddresses
+
+ // Date:
+ char tmpbuf[MAILTMPLEN];
+ rfc822_date (tmpbuf);
+ m_Envelope->date = cpystr(tmpbuf);
+
+ // Message-Id:
+ m_Envelope->message_id = cpystr(BuildMessageId(m_DefaultHost));
+
// don't add any more headers to the message being resent
- if ( !m_Envelope->remail )
+ if ( m_Envelope->remail )
{
+ return;
+ }
+
+ // the headers needed only for new (and not resent) messages
+ // ---------------------------------------------------------
+
/*
Is the message supposed to be sent later? In that case, we need
@@ -1122,11 +1192,4 @@
mail_free_body(&oldbody);
}
- }
-
- // finally, set the date
- char tmpbuf[MAILTMPLEN];
- rfc822_date (tmpbuf);
- m_Envelope->date = (char *) fs_get (1+strlen (tmpbuf));
- strcpy (m_Envelope->date,tmpbuf);
}
_______________________________________________________________
Sponsored by:
ThinkGeek at http://www.ThinkGeek.com/
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates