--- a/wp/wp-mail.php Thu Sep 29 08:06:27 2022 +0200
+++ b/wp/wp-mail.php Fri Sep 05 18:40:08 2025 +0200
@@ -65,6 +65,9 @@
wp_die( __( 'There does not seem to be any new mail.' ) );
}
+// Always run as an unauthenticated user.
+wp_set_current_user( 0 );
+
for ( $i = 1; $i <= $count; $i++ ) {
$message = $pop3->get( $i );
@@ -104,7 +107,7 @@
$content_transfer_encoding = explode( ';', $content_transfer_encoding );
$content_transfer_encoding = $content_transfer_encoding[0];
}
- if ( ( 'multipart/alternative' === $content_type ) && ( false !== strpos( $line, 'boundary="' ) ) && ( '' === $boundary ) ) {
+ if ( 'multipart/alternative' === $content_type && str_contains( $line, 'boundary="' ) && '' === $boundary ) {
$boundary = trim( $line );
$boundary = explode( '"', $boundary );
$boundary = $boundary[1];
@@ -134,8 +137,6 @@
}
$author = sanitize_email( $author );
if ( is_email( $author ) ) {
- /* translators: %s: Post author email address. */
- echo '<p>' . sprintf( __( 'Author is %s' ), $author ) . '</p>';
$userdata = get_user_by( 'email', $author );
if ( ! empty( $userdata ) ) {
$post_author = $userdata->ID;
@@ -146,7 +147,7 @@
if ( preg_match( '/Date: /i', $line ) ) { // Of the form '20 Mar 2002 20:32:37 +0100'.
$ddate = str_replace( 'Date: ', '', trim( $line ) );
- // Remove parenthesised timezone string if it exists, as this confuses strtotime().
+ // Remove parenthesized timezone string if it exists, as this confuses strtotime().
$ddate = preg_replace( '!\s*\(.+\)\s*$!', '', $ddate );
$ddate_timestamp = strtotime( $ddate );
$post_date = gmdate( 'Y-m-d H:i:s', $ddate_timestamp + $time_difference );
@@ -170,7 +171,7 @@
$content = explode( '--' . $boundary, $content );
$content = $content[2];
- // Match case-insensitive content-transfer-encoding.
+ // Match case-insensitive Content-Transfer-Encoding.
if ( preg_match( '/Content-Transfer-Encoding: quoted-printable/i', $content, $delim ) ) {
$content = explode( $delim[0], $content );
$content = $content[1];
@@ -230,7 +231,7 @@
echo "\n" . $post_ID->get_error_message();
}
- // We couldn't post, for whatever reason. Better move forward to the next email.
+ // The post wasn't inserted or updated, for whatever reason. Better move forward to the next email.
if ( empty( $post_ID ) ) {
continue;
}