Closed qazwsdc closed 1 month ago
Hey @qazwsdc 👋
Sorry to hear about your struggles. This is surely not due to a misconfiguration on your end, and it's almost surely not caused by WP Mail SMTP itself — the fact that it happens occasionally points to either cURL itself, or the Mailgun API, or your server configuration.
Did you try:
curl -k https://api.mailgun.net/
on your local machine, or on your server? If it's the former, would you try the latter?
Also:
hi, PHP is 8.1.7 and I have do this: apt update apt install curl it says the curl is the newest version
I have tried the curl -k api.mailgun.net on my server and it's fine
Thanks for your feedback.
It'd be nice to try hitting the Mailgun API from your terminal right after you experience the issue in WP Mail SMTP. That way, we'd know it's the API being slow, rather than the client talking to it. In other words, as soon as you get a timeout error in WP Mail SMTP, hop on your server and:
curl -k api.mailgun.net
or even
traceroute api.mailgun.net
Another useful test would be to run a local installation of WP Mail SMTP with Mailgun setup, and try sending from your local server when you get a timeout on your "real" server. The idea with these tests is to understand if the problem is your server, or Mailgun.
curl -k api.mailgun.net it says curl: (7) Failed to connect to api.mailgun.net port 443: Connection timed out But when I tried the command again it worked......
Maybe I should use a proxy? How to use a proxy in WP Mail SMTP? Thanks!
@qazwsdc Thanks! It seems Mailgun is the culprit, in which case a proxy wouldn't help (since if Mailgun API doesn't reply, or does so too slowly, you'd still get timeouts when requesting it). Let's dig a bit deeper:
But this server has been running fine for a long time, the problem only appeared recently, and I didn't change any configuration. By the way I upgrade wordpress to 6.6 already
@qazwsdc I see! This just makes me think Mailgun has some sort of issue, as weird as that sounds (you're the only user reporting this issue right now). Let's dig deeper:
default_socket_timeout
in your php.ini file? Would you try raising it, and see if that makes any difference?I upgrade wordpress to 6.6, Now,it says "The test email may have been sent, but its reachability should be improved." Domain name check results: cURL error 28: Connection timed out after 5000 milliseconds BUT, the email was actually sent successfully, Should I continue to solve it or just ignore it?
about your question:
Just confirmed, there is still a chance of sending failure.
@sixFingers Perhaps the network environment in China is unstable.How to use proxy in this WP-mail-SMTP?
Hi @qazwsdc,
I think it might be an issue on your server and the default timeout times are getting reached quite often.
Please try to Increase the default cURL Timeouts:
Add this to your theme's functions.php or in a site-specific plugin:
function qazwsdc_increase_curl_timeout( $handle ) {
curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, 30 ); // 30 seconds
curl_setopt( $handle, CURLOPT_TIMEOUT, 30 ); // 30 seconds
}
add_action( 'http_api_curl', 'qazwsdc_increase_curl_timeout' );
Let us know if this will resolve it.
@capuderg hi, I have changed to bravo and everything is Ok.So it's mailgun problem.Thanks
Thank you for letting us know!
With that information, I suspect that Mailgun might be blocking some of the requests from China.
Expected Behavior
send mail using Mailgun
Current Behavior
Mailer: Mailgun http_request_failed: ["cURL error 28: Connection timed out after 10000 milliseconds"]
I'm sure there's nothing wrong with the settings, this only happens occasionally and has become more frequent recently. I have tested this command: curl -k https://api.mailgun.net and it's fine