View Issue Details

IDProjectCategoryView StatusLast Update
0015538phpList 3 applicationCampaign Send Processpublic29-04-11 19:28
Reporterh2b2 
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

viewforum.php?f=22

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.
http://foobar.lamp-solutions.de/howtos/programmierung/einzelansicht-programierung/article/phplist-e-mails-ueber-mehrere-server-versenden.html

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

config.php
      //just insert at the end of the file
      $smtparray = array("server1.tld", "server2.tld", "server3.tld");
      if(!is_array($smtparray)){
      $smtparray[]=PHPMAILERHOST;
      }


sendemaillib.php

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

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


processqueue.php

      //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
      //old:
      $success = sendEmail($messageid,$useremail,$userhash,$htmlpref,$rssitems);
      //new:
      $success = sendEmail($smtphost,$messageid,$useremail,$userhash,$htmlpref,$rssitems);

class.phplistmailer.php

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

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


===== End Quote =====
ref: http://forums.phplist.com/viewtopic.php?f=18&t=33151
TagsNo tags attached.

Activities

lygie

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"];
if($mailhost["smtp_login"]!=''){
  $this->Username = $mailhost["smtp_login"];
}
if($mailhost["smtp_passwd"]!=''){
  $this->Password = $mailhost["smtp_passwd"];
}

michiel

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.