Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending emails through PHP mail is slow

Tags:

php

I have a large board with 1 million+ members and I'm experiencing great lag between the sending of emails to each member. At the current rate it would literally take me 3 months to send emails to all 1 million members.

My machine (dedicated):

  • dual quad xeon
  • 32 gigs of ram
  • Centos 5.4
  • vBulletin

I've tried configuring it a number of ways and it is still slow.

The resolution is done locally, so I don't think that's the issue. Any suggestions?


vBulletin shows as it sends out the emails (500 at a time) so I know the script isn't timing out or a memory issue. To complete a page of 500, it takes 10 minutes. I am using PHP's mail() function, which is the only other option I have other than SMTP. With previous servers I have not configured myself, it had always been fast. Now trying it with sendmail (PHP's mail function) it is so slow.

like image 706
John Avatar asked Jun 17 '11 01:06

John


2 Answers

Check your /etc/hosts file.

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

75.23.123.21 my-server-hostname

Change it to:

127.0.0.1 my-server-hostname

Then try running the PHP mail() function again.

like image 128
Travis Avatar answered Sep 22 '22 00:09

Travis


I'm going to say if you have 1 million subscribers you need to reach, perhaps it's better that you not do yourself. Instead, why not use a service like Mailchimp who's primary focus is on delivering email.

Think about the advantages:

  1. You don't worry about bandwidth, infrastructure and maintenance.

  2. You get comprehensive analytics on how your email campaigns are performing and the health of your list - you say you have a million emails but how many of them bounce back? How many are opened? what is the open rate per country?, how many are marked as spam etc?

  3. Depending on what your business is, you can A/B test your campaigns and optimize reads/clicks/conversions.

You will obviously pay extra for this service which is separate from your current hosting costs, but with Mailchimp you pay for what you use. Also if you can reach a million humans, you probably figured out how to monetize it (if not, you really should). So using a 3rd party service might pay for itself.

Mailchimp is one of many services out there (I mention it because I use it and very happy 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 this is just my $0.02.

P.S: Mailchimp also gives you an API so you can seamlessly integrate your app with their services.

like image 29
Jay Sidri Avatar answered Sep 21 '22 00:09

Jay Sidri