Merge pull request #63 from bluetiger9/master

Added Reply-To support
This commit is contained in:
Attila Tőkés 2017-12-22 10:47:43 +02:00 committed by GitHub
commit ca43f9d642
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 4 deletions

View File

@ -24,6 +24,7 @@
/* [1] Constructors and Destructors */
MimeMessage::MimeMessage(bool createAutoMimeContent) :
replyTo(Q_NULLPTR),
hEncoding(MimePart::_8Bit)
{
if (createAutoMimeContent)
@ -58,6 +59,10 @@ void MimeMessage::setContent(MimePart *content) {
this->content = content;
}
void MimeMessage::setReplyTo(EmailAddress* rto) {
replyTo = rto;
}
void MimeMessage::setSender(EmailAddress* e)
{
this->sender = e;
@ -135,6 +140,10 @@ const QList<EmailAddress*> & MimeMessage::getRecipients(RecipientType type) cons
}
}
const EmailAddress* MimeMessage::getReplyTo() const {
return replyTo;
}
const QString & MimeMessage::getSubject() const
{
return subject;
@ -253,9 +262,31 @@ QString MimeMessage::toString()
default:
mime += subject;
}
mime += "\r\n";
/* ---------------------------------- */
/* ---------- Reply-To -------------- */
if (replyTo) {
mime += "Reply-To: ";
if (replyTo->getName() != "")
{
switch (hEncoding)
{
case MimePart::Base64:
mime += " =?utf-8?B?" + QByteArray().append(replyTo->getName()).toBase64() + "?=";
break;
case MimePart::QuotedPrintable:
mime += " =?utf-8?Q?" + QuotedPrintable::encode(QByteArray().append(replyTo->getName())).replace(' ', "_").replace(':',"=3A") + "?=";
break;
default:
mime += " " + replyTo->getName();
}
}
mime += " <" + replyTo->getAddress() + ">\r\n";
}
/* ---------------------------------- */
mime += "\r\n";
mime += "MIME-Version: 1.0\r\n";
if (!mInReplyTo.isEmpty())
{

View File

@ -53,6 +53,7 @@ public:
void addBcc(EmailAddress* rcpt);
void setSubject(const QString & subject);
void addPart(MimePart* part);
void setReplyTo(EmailAddress* rto);
void setInReplyTo(const QString& inReplyTo);
@ -62,6 +63,7 @@ public:
const QList<EmailAddress*> & getRecipients(RecipientType type = To) const;
const QString & getSubject() const;
const QList<MimePart*> & getParts() const;
const EmailAddress* getReplyTo() const;
MimePart& getContent();
void setContent(MimePart *content);
@ -79,6 +81,7 @@ protected:
/* [4] Protected members */
EmailAddress* sender;
EmailAddress* replyTo;
QList<EmailAddress*> recipientsTo, recipientsCc, recipientsBcc;
QString subject;
QString mInReplyTo;