Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Reply-To header support #162

Merged
merged 1 commit into from
Jul 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading