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

Fix email multipart boundary #2693

Merged
merged 2 commits into from
Jan 5, 2024
Merged
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
20 changes: 13 additions & 7 deletions includes/class-wp-job-manager-email-notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class WP_Job_Manager_Email_Notifications {
const EMAIL_SETTING_PREFIX = 'job_manager_email_';
const EMAIL_SETTING_ENABLED = 'enabled';
const EMAIL_SETTING_PLAIN_TEXT = 'plain_text';
const MULTIPART_BOUNDARY = '--jm-boundary';
const MULTIPART_BOUNDARY = 'jm-boundary';

/**
* Notifications to be scheduled.
Expand Down Expand Up @@ -976,6 +976,15 @@ private static function get_styles() {
private static function get_multipart_body( string $content_html, string $content_plain ): string {
$multipart_body = '';

if ( ! empty( $content_plain ) ) {

$multipart_body .= '
--' . self::MULTIPART_BOUNDARY . '
Content-Type: text/plain; charset="utf-8"
' . $content_plain;
}

if ( ! empty( $content_html ) ) {
$multipart_body .= '
--' . self::MULTIPART_BOUNDARY . '
Expand All @@ -984,13 +993,10 @@ private static function get_multipart_body( string $content_html, string $conten
' . $content_html;
}

if ( ! empty( $content_plain ) ) {

if ( ! empty( $multipart_body ) ) {
$multipart_body .= '
--' . self::MULTIPART_BOUNDARY . '
Content-Type: text/plain; charset="utf-8"
' . $content_plain;
--' . self::MULTIPART_BOUNDARY . '--
';
}

return $multipart_body;
Expand Down
Loading