Skip to content

Commit

Permalink
Add Reply-To header support (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
schwestSICKAG authored Jul 27, 2024
1 parent 5da1857 commit db45937
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/mimemessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ void MimeMessage::setSender(const EmailAddress &sender)
this->sender = sender;
}

void MimeMessage::setReplyTo(const EmailAddress &replyTo)
{
this->replyTo = replyTo;
}

void MimeMessage::addRecipient(const EmailAddress &rcpt, RecipientType type)
{
switch (type)
Expand Down Expand Up @@ -114,6 +119,11 @@ EmailAddress MimeMessage::getSender() const
return sender;
}

EmailAddress MimeMessage::getReplyTo() const
{
return replyTo;
}

const QList<EmailAddress> & MimeMessage::getRecipients(RecipientType type) const
{
switch (type)
Expand Down Expand Up @@ -193,6 +203,12 @@ void MimeMessage::writeToDevice(QIODevice &out) const {
header.append("From:" + formatAddress(sender, hEncoding) + "\r\n");
/* ---------------------------------- */

/* ---------- Reply-To ----------- */
if (!replyTo.getAddress().isEmpty()) {
header.append("Reply-To:" + formatAddress(replyTo, hEncoding) + "\r\n");
}
/* ---------------------------------- */

/* ------- Recipients / To ---------- */
header.append("To:");
for (int i = 0; i<recipientsTo.size(); ++i)
Expand Down
3 changes: 3 additions & 0 deletions src/mimemessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class SMTP_MIME_EXPORT MimeMessage : public QObject
/* [2] Getters and Setters */

void setSender(const EmailAddress &sndr);
void setReplyTo(const EmailAddress &repto);
void addRecipient(const EmailAddress &rcpt, RecipientType type = To);
void addTo(const EmailAddress &rcpt);
void addCc(const EmailAddress &rcpt);
Expand All @@ -60,6 +61,7 @@ class SMTP_MIME_EXPORT MimeMessage : public QObject
void setHeaderEncoding(MimePart::Encoding);

EmailAddress getSender() const;
EmailAddress getReplyTo() const;
const QList<EmailAddress> &getRecipients(RecipientType type = To) const;
QString getSubject() const;
const QStringList &getCustomHeaders() const;
Expand All @@ -82,6 +84,7 @@ class SMTP_MIME_EXPORT MimeMessage : public QObject
/* [4] Protected members */

EmailAddress sender;
EmailAddress replyTo;
QList<EmailAddress> recipientsTo, recipientsCc, recipientsBcc;
QString subject;
QStringList customHeaders;
Expand Down

0 comments on commit db45937

Please sign in to comment.