From cb85660b426d31afdf90b3a94b617bb73d7eb400 Mon Sep 17 00:00:00 2001 From: Till Adam Date: Thu, 22 Dec 2005 12:12:07 +0000 Subject: [PATCH] Forward port of: SVN commit 490568 by tilladam: Implement a non-gui-exposed option to allow sending of MDN messages with an SMTP MAIL FROM of <>, which conforms to the rfc, but doesn't work with many real world servers, since they discard such messages for spam protection. Still, integrators might want to set it, via Kiosk, for example. svn path=/branches/KDE/3.5/kdepim/; revision=490571 --- kmail.kcfg | 8 ++++++++ kmsender.cpp | 30 ++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/kmail.kcfg b/kmail.kcfg index 1428258fd..3550ecc8a 100644 --- a/kmail.kcfg +++ b/kmail.kcfg @@ -443,4 +443,12 @@ + + + false + + Send Message Disposition Notifications with an empty sender string. Some servers might be configure to reject such messages, so if you are experiencing problems sendin MDNs, uncheck this option. + + + diff --git a/kmsender.cpp b/kmsender.cpp index 86b97d573..d848c18d2 100644 --- a/kmsender.cpp +++ b/kmsender.cpp @@ -25,6 +25,7 @@ using namespace KMime::Types; #include #include #include +#include "globalsettings.h" #include "kmfiltermgr.h" #include "kcursorsaver.h" @@ -40,6 +41,8 @@ using namespace KMime::Types; #include "protocols.h" #include "kmcommands.h" #include +#include +#include #define SENDER_GROUP "sending mail" @@ -236,6 +239,28 @@ void KMSender::emitProgressInfo( int currentFileProgress ) mProgressItem->setProgress(percent); } +static bool messageIsDispositionNotificationReport( KMMessage *msg ) +{ + if ( msg->type() == DwMime::kTypeMessage && + msg->subtype() == DwMime::kSubtypeDispositionNotification ) + return true; + + if ( msg->type() != DwMime::kTypeMultipart || + msg->subtype() != DwMime::kSubtypeReport ) + return false; + + DwMediaType& ct = msg->dwContentType(); + DwParameter *param = ct.FirstParameter(); + while( param ) { + if ( !qstricmp( param->Attribute().c_str(), "report-type") + && !qstricmp( param->Value().c_str(), "disposition-notification" ) ) + return true; + else + param = param->Next(); + } + return false; +} + //----------------------------------------------------------------------------- void KMSender::doSendMsg() { @@ -559,6 +584,11 @@ void KMSender::doSendMsgAux() QStringList to, cc, bcc; QString sender; extractSenderToCCAndBcc( mCurrentMsg, &sender, &to, &cc, &bcc ); + + // MDNs are required to have an empty envelope from as per RFC2298. + if ( messageIsDispositionNotificationReport( mCurrentMsg ) && GlobalSettings::self()->sendMDNsWithEmptySender() ) + sender = "<>"; + const QCString message = mCurrentMsg->asSendableString(); if ( sender.isEmpty() || !mSendProc->send( sender, to, cc, bcc, message ) ) { if ( mCurrentMsg )