I'm writing a simple API endpoint which allows a 3rd party site to create new users. Everything works but the 3rd party site is set up to only wait 5 seconds, and for some reason, when I create a new user and then call
wp_new_user_notification() it takes around 5 full seconds to send the response. Half the time the 3rd party site times out waiting.
When I comment out the new user notification, it's almost instant. So I know the slowness is coming from that line of code. I have two plugins that deal with new user emails, but I experimented by deactivating both of them and it's still slow. Any ideas why this is happening? I looked at the source code for the function, and it doesn't look like it should take that long.
Thanks for any advice you can give me!
I did a test using
$time3 = time(); wp_mail( "firstname.lastname@example.org", "SUBJECT", "MESSAGE" ); $time4 = time(); echo "wp_mail(): ". ($time4 - $time3);
And I get back
I think this suggests that the delay is inside
wp_new_user_notification() but outsidewp_mail()`.
UPDATE2: I'm not receiving any email from wp_mail() when I use it in my plugin. Perhaps there's some dependency that I'm missing.