Eduardo
Eduardo

Reputation: 51

PHP too slow when sending emails through external SMTP server

I have developed a PHP site to deliver a newsletter to subscribers through email using PHPMailer.

We had it hosted in a webhosting and it worked fine. We moved to a new dedicated server and everything works faster, except the email sending.

Now it's unacceptably slow. It takes 5 seconds to send each email. (we have 200 subscribers right now, and growing)

I have traced the PHP code and I see the problem is the communication with the external SMTP Server (we use TurboSMTP). It takes 1 second each step in the communication (login, authentication, sending...)

I've use the curl_exec function to see the time to connect to some servers and I'm getting 1.2 seconds to TurboSMTP, and les than 0.1 seconds to Google, Gmail, and many other well known sites.

I verified that the Hosts file in Windows has this server correctly set. I tried using the IP address instead the server name, and I get the same result. A "ping" to the TurboSMTP server (pro.turbo-smtp.com) is fast, as fast a to the IP 199.187.175.15

My server is a Windows Server 2008 R2 with IIS.

I've compared the configuration of the PHP ini in my new server with the old one, and I don't see substantial differences... (I don't have the ini file of the old server, but i can see the configuration of the PHP)

Any idea? I've been wasting time for two weeks with this and my users are loosing their patience... :( Thanks in advance!

Upvotes: 2

Views: 1337

Answers (1)

Eduardo
Eduardo

Reputation: 51

Apparently MonkeyZeus was right. I used Wireshark to snif the net and see what was taking so long... And I found there is nothing especifically slow...

It's just taking that time the handshaking and the communication itself.

The problem is that I migrated the server from one hosting in California, to a dedicated server in Buenos Aires, and the SMTP server is in NewYork.

Believe it or not, the distance does matter.

Every communication with the server means 10.000 km to go, and another 10.000 km back (Assuming we have an optical fiber that goes stright from Buenos Aires to NewYork) even at light speed, this 20.000 km round trip mean almost 70 miliseconds... And if we do the math... it takes seconds to send an email. HTH

Upvotes: 2

Related Questions