Make WordPress Core

Ticket #209: 0000209-email_mime.diff

File 0000209-email_mime.diff, 4.3 KB (added by crculver, 20 years ago)
  • wp-admin/users.php

    diff -ur wordpress-current/wp-admin/users.php wordpress-working/wp-admin/users.php
    old new  
    9595        $message  = 'New user registration on your blog ' . get_settings('blogname') . ":\r\n\r\n";
    9696        $message .= "Login: $user_login\r\n\r\nE-mail: $user_email";
    9797
    98         @mail(get_settings('admin_email'), '[' . get_settings('blogname') . '] New User Registration', $message);
     98        @mail_encoded(get_settings('admin_email'), '[' . get_settings('blogname') . '] New User Registration', $message);
    9999        header('Location: users.php');
    100100break;
    101101
  • wp-includes/functions.php

    diff -ur wordpress-current/wp-includes/functions.php wordpress-working/wp-includes/functions.php
    old new  
    982982        $notify_message .= get_permalink($comment->comment_post_ID) . '#comments';
    983983
    984984        if ('' == $comment->comment_author_email || '' == $comment->comment_author) {
    985                 $from = "From: \"$blogname\" <wordpress@" . $_SERVER['SERVER_NAME'] . '>';
     985                $from = "\"$blogname\" <wordpress@" . $_SERVER['SERVER_NAME'] . '>';
    986986        } else {
    987                 $from = 'From: "' . $comment->comment_author . "\" <$comment->comment_author_email>";
     987                $from = '"' . $comment->comment_author . "\" <$comment->comment_author_email>";
    988988        }
    989989
    990         $message_headers = "MIME-Version: 1.0\r\n"
    991                 . "$from\r\n"
    992                 . "Content-Type: text/plain; charset=\"" . get_settings('blog_charset') . "\"\r\n";
    993 
    994         @mail($user->user_email, $subject, $notify_message, $message_headers);
     990        @mail_encoded($user->user_email, $subject, $notify_message, $from);
    995991   
    996992    return true;
    997993}
     
    10251021
    10261022    $subject = '[' . get_settings('blogname') . '] Please approve: "' .$post->post_title.'"';
    10271023    $admin_email = get_settings("admin_email");
    1028     $from  = "From: $admin_email";
    1029 
    1030     $message_headers = "MIME-Version: 1.0\r\n"
    1031         . "$from\r\n"
    1032         . "Content-Type: text/plain; charset=\"" . get_settings('blog_charset') . "\"\r\n";
    10331024
    1034     @mail($admin_email, $subject, $notify_message, $message_headers);
     1025    @mail_encoded($admin_email, $subject, $notify_message, $admin_email);
    10351026   
    10361027    return true;
    10371028}
     
    15801571        endif;
    15811572}
    15821573
     1574function mail_encoded($to, $subject, $message, $from=''){
     1575
     1576        $charset = get_settings('blog_charset');
     1577 
     1578        # prepare headers
     1579
     1580        $message_headers = "MIME-Version: 1.0\r\n";
     1581        if ($from){
     1582                $message_headers .= "From: $from\r\n";
     1583        }
     1584        $message_headers .= "Content-Type: text/plain; charset=\"$charset\"\r\n";
     1585
     1586
     1587        # escape subject
     1588
     1589        $subject = preg_replace('/([^a-z ])/ie', 'sprintf("=%02x",ord(StripSlashes("\\1")))', $subject);
     1590        $subject = str_replace(' ', '_', $subject);
     1591        $subject = "=?$charset?Q?$subject?=";
     1592
     1593
     1594        @mail($to, $subject, $message, $message_headers);
     1595}
     1596
    15831597function wp_head() {
    15841598        do_action('wp_head', '');
    15851599}
  • wp-login.php

    diff -ur wordpress-current/wp-login.php wordpress-working/wp-login.php
    old new  
    216216        $message .= "Password: $user_pass\r\n";
    217217        $message .= 'Login at: ' . get_settings('siteurl') . '/wp-login.php';
    218218
    219         $m = mail($user_email, '[' . get_settings('blogname') . "] Your weblog's login/password", $message);
     219        $m = mail_encoded($user_email, '[' . get_settings('blogname') . "] Your weblog's login/password", $message);
    220220
    221221        if ($m == false) {
    222222                 echo '<p>' . __('The e-mail could not be sent.') . "<br />\n";
     
    226226                echo '<p>' .  sprintf(__("The e-mail was sent successfully to %s's e-mail address."), $user_login) . '<br />';
    227227        echo  "<a href='wp-login.php' title='" . __('Check your e-mail first, of course') . "'>" . __('Click here to login!') . '</a></p>';
    228228                // send a copy of password change notification to the admin
    229                 mail(get_settings('admin_email'), sprintf(__('[%s] Password Lost/Change'), get_settings('blogname')), sprintf(__('Password Lost and Changed for user: %s'), $user_login));
     229                mail_encoded(get_settings('admin_email'), sprintf(__('[%s] Password Lost/Change'), get_settings('blogname')), sprintf(__('Password Lost and Changed for user: %s'), $user_login));
    230230                die();
    231231        }
    232232