Skip to content

Fix an issue with feedback emails with text and html body, and an attachment. #2694

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

Open
wants to merge 1 commit into
base: WeBWorK-2.20
Choose a base branch
from
Open
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
13 changes: 13 additions & 0 deletions lib/WeBWorK/ContentGenerator/Feedback.pm
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,19 @@ sub initialize ($c) {
return;
}

# Email::Stuffer incorrectly adds the attachment together with the text and html body parts at the same
# level. As a result, when an email has a text body, an html body, and an attachment, both the text and
# html are shown in most email clients. The text and html body should be parts of a separate part that has
# content type 'multipart/alternative'. So the email has two parts, and the first part has two parts which
# are the text and html body. The second part is the attachment. So before attaching the file move the text
# and html body into their own part.
$email->{parts} = [
Email::MIME->create(
attributes => { content_type => 'multipart/alternative' },
parts => $email->{parts}
)
];

# Attach the file.
$email->attach($contents, filename => $filename);
}
Expand Down