wp_mail example

/** * Filters the comment notification email headers. * * @since 1.5.2 * * @param string $message_headers Headers for the comment notification email. * @param string $comment_id Comment ID as a numeric string. */
        $message_headers = apply_filters( 'comment_notification_headers', $message_headers$comment->comment_ID );

        foreach ( $emails as $email ) {
            wp_mail( $emailwp_specialchars_decode( $subject )$notify_message$message_headers );
        }

        if ( $switched_locale ) {
            restore_previous_locale();
        }

        return true;
    }
endif;

if ( ! function_exists( 'wp_notify_moderator' ) ) :
    

        $email = apply_filters( 'recovery_mode_email', $email$url );

        $sent = wp_mail(
            $email['to'],
            wp_specialchars_decode( sprintf( $email['subject']$blogname ) ),
            $email['message'],
            $email['headers'],
            $email['attachments']
        );

        if ( $switched_locale ) {
            restore_previous_locale();
        }

        

            $new_user_email = apply_filters( 'invited_user_email', $new_user_email$user_id$role$newuser_key );

            wp_mail(
                $new_user_email['to'],
                $new_user_email['subject'],
                $new_user_email['message'],
                $new_user_email['headers']
            );

            if ( $switched_locale ) {
                restore_previous_locale();
            }

            $redirect = add_query_arg( array( 'update' => 'add' ), 'user-new.php' );
        }

    $headers = apply_filters( 'wp_privacy_personal_data_email_headers', $headers$subject$content$request_id$email_data );

    $mail_success = wp_mail( $request_email$subject$content$headers );

    if ( $switched_locale ) {
        restore_previous_locale();
    }

    if ( ! $mail_success ) {
        return new WP_Error( 'privacy_email_error', __( 'Unable to send personal data export email.' ) );
    }

    return true;
}


        $installed_email = apply_filters( 'wp_installed_email', $installed_email$user$blog_title$blog_url$password );

        wp_mail(
            $installed_email['to'],
            $installed_email['subject'],
            $installed_email['message'],
            $installed_email['headers']
        );
    }
endif;

if ( ! function_exists( 'wp_upgrade' ) ) :
    /** * Runs WordPress Upgrade functions. * * Upgrades the database if needed during a site update. * * @since 2.1.0 * * @global int $wp_current_db_version The old (current) database version. * @global int $wp_db_version The new database version. * @global wpdb $wpdb WordPress database abstraction object. */
$content      = str_replace( '###ADMIN_URL###', esc_url( self_admin_url( 'options.php?adminhash=' . $hash ) )$content );
    $content      = str_replace( '###EMAIL###', $value$content );
    $content      = str_replace( '###SITENAME###', wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES )$content );
    $content      = str_replace( '###SITEURL###', home_url()$content );

    if ( '' !== get_option( 'blogname' ) ) {
        $site_title = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
    } else {
        $site_title = parse_url( home_url(), PHP_URL_HOST );
    }

    wp_mail(
        $value,
        sprintf(
            /* translators: New admin email address notification email subject. %s: Site title. */
            __( '[%s] New Admin Email Address' ),
            $site_title
        ),
        $content
    );

    if ( $switched_locale ) {
        restore_previous_locale();
    }

        $email = apply_filters( 'auto_core_update_email', $email$type$core_update$result );

        wp_mail( $email['to']wp_specialchars_decode( $email['subject'] )$email['body']$email['headers'] );
    }


    /** * Checks whether an email should be sent after attempting plugin or theme updates. * * @since 5.5.0 * * @param array $update_results The results of update tasks. */
    protected function after_plugin_theme_update( $update_results ) {
        

        $pass_change_email = apply_filters( 'password_change_email', $pass_change_email$user$userdata );

        $pass_change_email['message'] = str_replace( '###USERNAME###', $user['user_login']$pass_change_email['message'] );
        $pass_change_email['message'] = str_replace( '###ADMIN_EMAIL###', get_option( 'admin_email' )$pass_change_email['message'] );
        $pass_change_email['message'] = str_replace( '###EMAIL###', $user['user_email']$pass_change_email['message'] );
        $pass_change_email['message'] = str_replace( '###SITENAME###', $blog_name$pass_change_email['message'] );
        $pass_change_email['message'] = str_replace( '###SITEURL###', home_url()$pass_change_email['message'] );

        wp_mail( $pass_change_email['to']sprintf( $pass_change_email['subject']$blog_name )$pass_change_email['message']$pass_change_email['headers'] );
    }

    if ( ! empty( $send_email_change_email ) ) {
        /* translators: Do not translate USERNAME, ADMIN_EMAIL, NEW_EMAIL, EMAIL, SITENAME, SITEURL: those are placeholders. */
        $email_change_text = __(
            'Hi ###USERNAME###, This notice confirms that your email address on ###SITENAME### was changed to ###NEW_EMAIL###. If you did not change your email, please contact the Site Administrator at ###ADMIN_EMAIL### This email has been sent to ###EMAIL### Regards, All at ###SITENAME### ###SITEURL###'

    $email_change_email = apply_filters( 'site_admin_email_change_email', $email_change_email$old_email$new_email );

    $email_change_email['message'] = str_replace( '###OLD_EMAIL###', $old_email$email_change_email['message'] );
    $email_change_email['message'] = str_replace( '###NEW_EMAIL###', $new_email$email_change_email['message'] );
    $email_change_email['message'] = str_replace( '###SITENAME###', $site_name$email_change_email['message'] );
    $email_change_email['message'] = str_replace( '###SITEURL###', home_url()$email_change_email['message'] );

    wp_mail(
        $email_change_email['to'],
        sprintf(
            $email_change_email['subject'],
            $site_name
        ),
        $email_change_email['message'],
        $email_change_email['headers']
    );
}

/** * Returns an anonymized IPv4 or IPv6 address. * * @since 4.9.6 Abstracted from `WP_Community_Events::get_unsafe_client_ip()`. * * @param string $ip_addr The IPv4 or IPv6 address to be anonymized. * @param bool $ipv6_fallback Optional. Whether to return the original IPv6 address if the needed functions * to anonymize it are not present. Default false, return `::` (unspecified address). * @return string The anonymized IP address. */
$path,
            $title,
            $user_login,
            $user_email,
            $key,
            $meta
        ),
        $from_name,
        esc_url( 'http://' . $domain . $path )
    );

    wp_mail( $user_emailwp_specialchars_decode( $subject )$message$message_headers );

    if ( $switched_locale ) {
        restore_previous_locale();
    }

    return true;
}

/** * Sends a confirmation request email to a user when they sign up for a new user account (without signing up for a site * at the same time). The user account will not become active until the confirmation link is clicked. * * This is the notification function used when no new site has * been requested. * * Filter {@see 'wpmu_signup_user_notification'} to bypass this function or * replace it with your own notification behavior. * * Filter {@see 'wpmu_signup_user_notification_email'} and * {@see 'wpmu_signup_user_notification_subject'} to change the content * and subject line of the email sent to newly registered users. * * @since MU (3.0.0) * * @param string $user_login The user's login name. * @param string $user_email The user's email address. * @param string $key The activation key created in wpmu_signup_user() * @param array $meta Optional. Signup meta data. Default empty array. * @return bool */

    $content = apply_filters( 'delete_site_email_content', $content );

    $content = str_replace( '###USERNAME###', $user->user_login, $content );
    $content = str_replace( '###URL_DELETE###', $url_delete$content );
    $content = str_replace( '###SITENAME###', get_network()->site_name, $content );
    $content = str_replace( '###SITEURL###', network_home_url()$content );

    wp_mail(
        get_option( 'admin_email' ),
        sprintf(
            /* translators: %s: Site title. */
            __( '[%s] Delete My Site' ),
            wp_specialchars_decode( get_option( 'blogname' ) )
        ),
        $content
    );

    if ( $switched_locale ) {
        restore_previous_locale();
    }
Home | Imprint | This part of the site doesn't use cookies.