summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Jarvie <djarvie@kde.org>2012-07-14 19:16:11 (GMT)
committerDavid Jarvie <djarvie@kde.org>2012-07-14 19:16:53 (GMT)
commit8df2bafc557cd19a08fcfe8c5ff048efc8013397 (patch)
tree45f1621ff26f1b3f136e288c70e604ec0c144dd8
parent989a15d79a16fd3a0332e23085442bc57f9fe150 (diff)
Bug 301946: fix sender address errors sending emails
Fix failure to send emails for some users, with the error message: "The server did not accept the sender address ..." Thanks to Laurent Montel for identifying the problem and providing a fix. Backport of f4ea2ad3a3044206fb5c0b1cb986d33248efbe98 (master).
-rw-r--r--kalarm/Changelog3
-rw-r--r--kalarm/kamail.cpp30
2 files changed, 28 insertions, 5 deletions
diff --git a/kalarm/Changelog b/kalarm/Changelog
index 4e4ab6a..27216be 100644
--- a/kalarm/Changelog
+++ b/kalarm/Changelog
@@ -1,10 +1,11 @@
KAlarm Change Log
-=== Version 2.8.6 --- 24 June 2012 ===
+=== Version 2.8.6 (KDE 4.8.5) --- 14 July 2012 ===
- [Akonadi] Don't display calendars which have no Akonadi resource.
- [Akonadi resources] Fix resource if config is missing.
- [Akonadi resources] Make resource work if location is set by path OR URL.
- Fix crash when closing alarm window for alarm which plays audio file.
+- Fix "server did not accept the sender address" errors sending emails.
=== Version 2.8.5 (KDE 4.8.4) --- 6 June 2012 ===
- [Akonadi] Warn user and disable KAlarm if Akonadi fails to run.
diff --git a/kalarm/kamail.cpp b/kalarm/kamail.cpp
index 8a01d2a..6e5e2d5 100644
--- a/kalarm/kamail.cpp
+++ b/kalarm/kamail.cpp
@@ -82,6 +82,8 @@ bool parseAddress( const char* & scursor, const char * const send,
static void initHeaders(KMime::Message&, KAMail::JobData&);
static KMime::Types::Mailbox::List parseAddresses(const QString& text, QString& invalidItem);
+static QString extractEmailAndNormalize(const QString& emailAddress);
+static QStringList extractEmailsAndNormalize(const QString& emailAddresses);
static QByteArray autoDetectCharset(const QString& text);
static const QTextCodec* codecForName(const QByteArray& str);
@@ -102,7 +104,6 @@ KAMail* KAMail::instance()
return mInstance;
}
-
/******************************************************************************
* Send the email message specified in an event.
* Reply = 1 if the message was sent - 'errmsgs' may contain copy error messages.
@@ -213,10 +214,12 @@ int KAMail::send(JobData& jobdata, QStringList& errmsgs)
MailTransport::MessageQueueJob* mailjob = new MailTransport::MessageQueueJob(kapp);
mailjob->setMessage(message);
mailjob->transportAttribute().setTransportId(transport->id());
- mailjob->addressAttribute().setFrom(jobdata.from);
- mailjob->addressAttribute().setTo(jobdata.event.emailAddresses());
+ // MessageQueueJob email addresses must be pure, i.e. without display name. Note
+ // that display names are included in the actual headers set up by initHeaders().
+ mailjob->addressAttribute().setFrom(extractEmailAndNormalize(jobdata.from));
+ mailjob->addressAttribute().setTo(extractEmailsAndNormalize(jobdata.event.emailAddresses(",")));
if (!jobdata.bcc.isEmpty())
- mailjob->addressAttribute().setBcc(QStringList(KPIMUtils::extractEmailAddress(jobdata.bcc)));
+ mailjob->addressAttribute().setBcc(extractEmailsAndNormalize(jobdata.bcc));
MailTransport::SentBehaviourAttribute::SentBehaviour sentAction =
(Preferences::emailClient() == Preferences::kmail || Preferences::emailCopyToKMail())
? MailTransport::SentBehaviourAttribute::MoveToDefaultSentCollection : MailTransport::SentBehaviourAttribute::Delete;
@@ -657,6 +660,25 @@ QString KAMail::getMailBody(quint32 serialNumber)
}
#endif
+/******************************************************************************
+* Extract the pure addresses from given email addresses.
+*/
+QString extractEmailAndNormalize(const QString& emailAddress)
+{
+ return KPIMUtils::extractEmailAddress(KPIMUtils::normalizeAddressesAndEncodeIdn(emailAddress));
+}
+
+QStringList extractEmailsAndNormalize(const QString& emailAddresses)
+{
+ const QStringList splitEmails(KPIMUtils::splitAddressList(emailAddresses));
+ QStringList normalizedEmail;
+ Q_FOREACH(const QString& email, splitEmails)
+ {
+ normalizedEmail << KPIMUtils::extractEmailAddress(KPIMUtils::normalizeAddressesAndEncodeIdn(email));
+ }
+ return normalizedEmail;
+}
+
//-----------------------------------------------------------------------------
// Based on KMail KMMsgBase::autoDetectCharset().
QByteArray autoDetectCharset(const QString& text)