wp_mail发送多封电子邮件

I have the following function in my themes function.php:

function user_profile_update( $user_id ) {
        $site_url = get_bloginfo('wpurl');
        $user_info = get_userdata( $user_id );
        $to = $user_info->user_email;
        $subject = "Profile Updated: ".$site_url."";
        $message = "Hello " .$user_info->display_name . "
Your profile has been updated!

Thank you for visiting
 ".$site_url."";
        wp_mail( $to, $subject, $message);
}
add_action( 'profile_update', 'user_profile_update');

This basically sends an email everytime a user updates there profile.

The email comes through fine but i get it 3-4 times. Does anything look out of place with the above?

You should probably set a priority for your action. Right now, you are getting a priority of 10 (the default if you don't define it). I would think that if you set a priority with a high number (to come late in the process), that might solve your issue.

add_action( 'profile_update', 'user_profile_update', 99, 2 );

Priority is the third argument passed to add_action with lower numbers being executed first. A high number (such as 99) will put it way at the end of execution. Even though priority and accepted arguments are not required, it is still a good habit to pass these (and define them if they are different than the default).