View Issue Details

IDProjectCategoryView StatusLast Update
0015538phpList 3 applicationCampaign Send Processpublic29-04-11 19:28
PrioritynormalSeverityfeatureReproducibilityhave not tried
Status newResolutionopen 
Product Version2.10.12 
Target VersionFixed in Version 
Summary0015538: Include load balancing feature to send emails through multiple servers
DescriptionLigie suggests the following code modifications to add a load balancing feature to phpList (v2.10.12):

===== Start quote =====
some time ago I posted some code in the german forum
that makes it possible to use more than one relay-host to send e-Mails


I am able to send several tenthousands emails within one hour without problems.

Every update of phplist i have to rebuild my code on all my phplist installations. I think it would be possible to modify the code and put this feature in phplist without problems.

I have tried to clearly arrange the code on my own website.

If there are any questions, or improvements, i will be glad to develop this feature.

For really large lists, the program has the disadvantage that it only sends the e-mails through one single SMTP host that is registered as a constant value in the config file.

Attempts to use several servers with Round Robin DNS load balancing were not successful.

However, load balancing is possible with some small adjustments to the program code. We will also try the above mentioned changes to give the developers so that they may find their way into future versions.

The adjustments needed consist of a few lines of code:

All line numbers refer to phplist version 2.10.12

      //just insert at the end of the file
      $smtparray = array("server1.tld", "server2.tld", "server3.tld");


      //line 23
      function sendEmail ($messageid,$email,$hash,$htmlpref = 0,$rssitems = \
      array(),$forwardedby = array()) {
      function sendEmail ($smtphost,$messageid,$email,$hash,$htmlpref = 0,$rssitems \
      = array(),$forwardedby = array()) {

      //line 609:
      $mail = new PHPlistMailer($messageid,$destinationemail)
      $mail = new PHPlistMailer($messageid,$destinationemail,$smtphost)


      //line 352
      $hosts_count = sizeof($smtparray);
      $host_divide = 60/$hosts_count;

      //line 641
      $date_s = date("s");
      $host_nr = floor ($date_s/$host_divide);
      $smtphost = $smtparray[$host_nr];

      //line 647
      $success = sendEmail($messageid,$useremail,$userhash,$htmlpref,$rssitems);
      $success = sendEmail($smtphost,$messageid,$useremail,$userhash,$htmlpref,$rssitems);


      //line 25
      function PHPlistMailer($messageid,$email) {
      function PHPlistMailer($messageid,$email,$mailhost) {

      //line 39
      $this->Host = PHPMAILERHOST;
      $this->Host = $mailhost;

===== End Quote =====
TagsNo tags attached.



25-09-10 09:57

reporter   ~0051089

After a reply in the forum, I updates the code so that you can provide different password for each smtp-Host

At the end of the config file, the should be lines like

#if you want do sent email over more than one smtp-Server, uncomment and fill following lines
$smtparray = array(
    "0" => array("hostname"=>"server1.tld","smtp_login"=>"username","smtp_passwd"=>"passwd"),
    "1" => array("hostname"=>"server2.tld","smtp_login"=>"username","smtp_passwd"=>"passwd"),
"2" => array("hostname"=>"server3.tld","smtp_login"=>"username","smtp_passwd"=>"passwd"),

The only thing that must be updated is class.phplistmailer.php

The part where hostname, passowrd, und username is defined should be:

$this->Host = $mailhost["hostname"];
  $this->Username = $mailhost["smtp_login"];
  $this->Password = $mailhost["smtp_passwd"];


29-04-11 19:28

manager   ~0051233

I think, but haven't tried, that phpMailer 5 which is in the latest dev version can do that. You can basically define your smtp server as something like

server1;server2;server3 and it'll rotate through them, or at least have a fallback.

however, for phpList to make better use of that, it would also be useful for phpList to allow more than just one send process.