Skip to content

Commit

Permalink
Fix email multipart boundary (#2693)
Browse files Browse the repository at this point in the history
* Fix email multipart boundary constant

* Improve compliance
  • Loading branch information
yscik authored Jan 5, 2024
1 parent 2374bce commit be029e6
Showing 1 changed file with 13 additions and 7 deletions.
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

0 comments on commit be029e6

Please sign in to comment.