Sending email via PHP mail is slow

I have a large board with 1 million + members, and I am lagging a lot between sending letters to each member. With the current course, it will literally take me 3 months to send letters to all 1 million members.

My car (dedicated):

  • dual quad xeon
  • 32 gigs ram
  • Centos 5.4
  • forum

I tried to configure it in several ways, and it is still slow.

Resolution is done locally, so I don't think the problem is. Any suggestions?


vBulletin shows that it sends emails (500 at a time), so I know that the script is out of sync or a memory problem. To complete page 500, it takes 10 minutes. I use the PHP mail() function, which is the only other option that I have besides SMTP. With previous servers, I did not configure myself, it was always fast. Now having tried it with sendmail (PHP mail function), it is so slow.

+6
source share
4 answers

Check the file /etc/hosts .

If you have an entry for your external IP address that points to your local host name, for example:

 75.23.123.21 my-server-hostname 

Change it to:

 127.0.0.1 my-server-hostname 

Then try again using the PHP mail() function.

+4
source

I will say if you have 1 million subscribers that you need to achieve, perhaps better if you do not do it yourself. Instead, why not use a service like Mailchimp , whose primary goal is email delivery.

Think about the benefits:

  • You don’t worry about bandwidth, infrastructure and service.

  • You get comprehensive analytics on how your email campaigns work and the health of your list β€” you say you have a million emails, but how many of them bounce? How many of them are open? What is the open rate for each country ?, how much is marked as spam, etc.?

  • Depending on your business, you can A / B test your campaigns and optimize reading / clicks / conversions.

Obviously, you will pay extra for this service, which is different from your current hosting costs, but with Mailchimp you pay for what you use. Also, if you can reach a million people, you probably figured out how to monetize it (if not, you really should). Therefore, the use of a third-party service can pay off.

Mailchimp is one of many services (I mention this because I use it and am very pleased with it). You might want to check out SendGrid , Campaign Monitor, and Aweber and weigh your pros and cons.

Probably not the answer you were expecting, but these are just my 0.02 dollars.

PS: Mailchimp also provides an API so you can easily integrate your application with your services.

+2
source

From the PHP manual

It is worth noting that the mail () function is not suitable for large volumes of email in a loop. This function opens and closes the SMTP socket for each message, which is not very efficient.

To send large volumes of email, see PEAR :: Mail and PEAR :: Mail_Queue .

+2
source

I'm far from an expert, but the mail () function uses a lot more CPU and memory than regular web functions, but 1 million users already have significant load (CPU and IO) on your server. This can affect the speed of sending emails, especially if you are on an earlier Xeon.

From what I know, the dual-core Xeon quad are relatively new, and sending these emails shouldn't go as close as once.

From what I read, a server with a dedicated server with one end should be able to send about 500-700 letters per minute ... but this is a system designed only for sending emails. On a server with an intermediate range, as I suspect, you have it, I expect it to be able to send letters in hours, not months.

This may be a configuration or load problem, which may be at different levels.

+1
source

Source: https://habr.com/ru/post/890724/


All Articles