Sending Using Multiple SMTP Servers Simultaneously

Solutions for other advanced phplisters

Sending Using Multiple SMTP Servers Simultaneously

Postby Guest » 5:23am, Fri 14 Nov, 2008

Hi,

I searched this board and while this question has been asked, it doesn't seem to have been answered so far.

And if anyone can answer it well enough to make it work for me, I will contribute $50 in your name to the project as a sign of appreciation.

I have a client with an email list that has 45k subscribers.

I use shared hosting that allows this program to be installed but the hosting company does not want me to send more than 100 emails per minute (and I am sure that phpList allows you to limit the send rate to 100 per minute, right?)

So with the client's sole hosting account, it would take 7.5 hours to send out an email to their subscribers. Really long time, eh?

However, across all of the hosting companies other servers, I have a total of twelve accounts. So that means when I send out a message, I could, in theory, use the SMTP server for each of them to send 100 emails each minute, and it would take 38 minutes to send to the entire list.

Not bad, eh?

So - how can I make phpList do this?

Thanks.
Guest
 

Postby CS » 1:06am, Sat 15 Nov, 2008

By default, PHPlist does not allow for this type of functionality. This would require custom programming. If you're interested in paid custom programming, you can either submit a request for paid support from the developers, or if you like, I'd be happy to provide you with a quote to provide you with the services myself.
CS
 

Re: Sending Using Multiple SMTP Servers Simultaneously

Postby rodrer » 11:33pm, Sat 27 Jun, 2009

Hi,

I created a structure using the "/admin/class.phplistmailer.php" and "/config/config.php" files.

It new structure do not send to Multiple SMTP Servers Simultaneously but it sent to various SMTP Servers sequentially, one server each time that one email is prepared to get sent.

With those new modifications you can choose how many SMTP Servers you will use to sent out emails with PHPList.

Se bellow my new "/config/config.php", I think that you will understand what are the modifications that I do on those files. The code is commented.

Will it solve your problems? If yes, please let me know.

Thank you,
Rodrigo





# If you want to use the PHPMailer class from phpmailer.sourceforge.net, set the following
# to 1. If you tend to send out html emails, it is recommended to do so.
define("PHPMAILER",1);

# To use a SMTP please give your server hostname here, leave it blank to use the standard
# PHP mail() command.
define("PHPMAILERHOST",'domain.com');

# if you want to use smtp authentication when sending the email uncomment the following
# two lines and set the username and password to be the correct ones
$phpmailer_smtpuser = 'login';
$phpmailer_smtppassword = 'password';



# To use MULTIPLE_SMTP_SERVERS set the number of servers here.
# It just will work if PHPMAILERHOST is set and if you set the $phpmailer_smtphost_N and $phpmailer_smtpuser and $phpmailer_smtppassword
# If you don't want to use it, leave it blank to use just one SMTP server or PHP mail() command.
define("MULTI_SMTP_SERVERS",'3');

# to avoid overloading the MULTIPLE servers that sends your email, you can add a little delay
# between messages that will spread the load of sending
# you will need to find a good value for your own server
# value is in seconds (or you can play with the multi_autothrottle below)
# remember multi_autothrottle will be used after pass into all the multi server structure
define("MULTI_SMTP_SERVERS_MAILQUEUE_THROTTLE",'1');

#
# WARNING: Don't forget to create the $phpmailer_smtphost_N configurations, with HOSTNAME/IP, LOGIN and PASSWORD as bellow for each SMTP SERVER.
# If MULTI_SMTP_SERVERS is set to 3 as: define("MULTI_SMTP_SERVERS",'3'); follow the example. You can add as many SMTP servers you want using
# this feature.
#
$phpmailer_smtphost_1 = 'domain.com';
$phpmailer_smtpuser_1 = 'login';
$phpmailer_smtppassword_1 = 'password';
#
$phpmailer_smtphost_2 = 'IP.IP.IP.IP';
$phpmailer_smtpuser_2 = 'login';
$phpmailer_smtppassword_2 = 'password';
#
$phpmailer_smtphost_3 = 'smtp.domain.com';
$phpmailer_smtpuser_3 = 'login';
$phpmailer_smtppassword_3 = 'password';
rodrer
phpList newbie
 
Posts: 4
Joined: 1:06pm, Wed 28 Jan, 2009

Re: Sending Using Multiple SMTP Servers Simultaneously

Postby peepfunk » 3:16pm, Wed 16 Sep, 2009

Hi rodrer,
It looks like what you've made is exactly what I'm looking for, but I'm confused as to how you set it up. What files do I need to add the code to and how can I specify, for example, to only send 200 emails per SMTP server (if that is even possible).
Hope you can help!
peepfunk
phpList newbie
 
Posts: 2
Joined: 12:21pm, Wed 16 Sep, 2009

Re: Sending Using Multiple SMTP Servers Simultaneously

Postby lestraw » 1:01am, Wed 14 Oct, 2009

which is the configuration of /admin/class.phplistmailer.php

http://forums.phplist.com/viewtopic.php?f=15&t=22296


Thanks beforehand, :D
lestraw
PL Geek
 
Posts: 59
Joined: 9:29pm, Sun 24 May, 2009

Re: Sending Using Multiple SMTP Servers Simultaneously

Postby mk2005 » 12:13pm, Wed 05 May, 2010

where is configuration in class.phplistmailer.php
mk2005
phpList newbie
 
Posts: 2
Joined: 12:00pm, Wed 05 May, 2010

Re: Sending Using Multiple SMTP Servers Simultaneously

Postby rodrer » 3:14am, Wed 21 Jul, 2010

I did not posted anything before cause I was testing this solution.

I'm not fully satisfied with this, but here is the modified /admin/class.phplistmailler.php :

<?php
require_once dirname(__FILE__).'/accesscheck.php';

## update to phpmailer v2 is not finished yet
# require( dirname(__FILE__) . '/phpmailer2/class.phpmailer.php');

require( dirname(__FILE__) . '/phpmailer/class.phpmailer.php');

class PHPlistMailer extends PHPMailer {
static $static_multi_smtp_server = MULTI_SMTP_SERVERS; //Static variable to MULTIPLE_SMTP_SERVERS
static $actual_smtp_server = 0; //If you're using MAX_SMTP_SERVERS here is the control to know what the next SMTP SERVER to use
var $isText = false;
var $WordWrap = 75;
var $encoding = 'base64';
var $image_types = array(
'gif' => 'image/gif',
'jpg' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'jpe' => 'image/jpeg',
'bmp' => 'image/bmp',
'png' => 'image/png',
'tif' => 'image/tiff',
'tiff' => 'image/tiff',
'swf' => 'application/x-shockwave-flash'
);

function PHPlistMailer($messageid,$email) {
# parent::PHPMailer();
parent::SetLanguage('en', dirname(__FILE__) . '/phpmailer/language/');
$this->addCustomHeader("X-Mailer: phplist v".VERSION);
$this->addCustomHeader("X-MessageID: $messageid");
$this->addCustomHeader("X-ListMember: $email");
$this->addCustomHeader("Precedence: bulk");
$this->CharSet = getConfig("html_charset");

if (defined('PHPMAILERHOST') && PHPMAILERHOST != '' && isset($GLOBALS['phpmailer_smtpuser']) && $GLOBALS['phpmailer_smtpuser'] != '') {
$this->SMTPAuth = true;
$this->Helo = getConfig("website");

# Just enter here if trying to use MULTI_SMTP_SERVERS
if(defined('MULTI_SMTP_SERVERS'))
{
# if the $actual_smtp_server if equal the $static_max_smtp_server, reset the counter
if(self::$actual_smtp_server == self::$static_multi_smtp_server)
{self::$actual_smtp_server = 0;}
else
{self::$actual_smtp_server++;}

# Set the current SMTP server
if(self::$actual_smtp_server == 0)
{
$this->Host = PHPMAILERHOST;
$this->Username = $GLOBALS['phpmailer_smtpuser'];
$this->Password = $GLOBALS['phpmailer_smtppassword'];
sleep(MULTI_SMTP_SERVERS_MAILQUEUE_THROTTLE);
logEvent("Server Base: ".$this->Host."#".$this->Username . " Sleep:" . MULTI_SMTP_SERVERS_MAILQUEUE_THROTTLE);
}
else
{
$this->Host = $GLOBALS["phpmailer_smtphost_".self::$actual_smtp_server];
$this->Username = $GLOBALS["phpmailer_smtpuser_".self::$actual_smtp_server];
$this->Password = $GLOBALS["phpmailer_smtppassword_".self::$actual_smtp_server];;
logEvent("Using server #".self::$actual_smtp_server.": ".$this->Host."#".$this->Username);
}

# This shows that we are using multiple SMTP servers. It will log what SMTP we are currently using.
logEvent('Sending via smtp. Max:'.self::$static_multi_smtp_server.' Current:'.self::$actual_smtp_server);
}
else
{
$this->Host = PHPMAILERHOST;
$this->Username = $GLOBALS['phpmailer_smtpuser'];
$this->Password = $GLOBALS['phpmailer_smtppassword'];
}
# logEvent('Sending authenticated email via '.PHPMAILERHOST);

logEvent('Sending via smtp');
$this->Mailer = "smtp";
}
else{
logEvent('Sending via mail');
$this->Mailer = "mail";
}

//$ip = gethostbyname($this->Host);

if ($GLOBALS["message_envelope"]) {
$this->Sender = $GLOBALS["message_envelope"];
$this->addCustomHeader("Errors-To: ".$GLOBALS["message_envelope"]);
}
}
...

The problem with this solutions is that every SMTP connection must wait the end of the prior connection to SMTP to try to send emails again, I'm trying to make some changes on the file /admin/processqueue.php to create some kind of MULTI_THREAD without the use of SO resources, just using PHP.

I'm working on this issue and as so possible I'll put it here.
Excuse me but I'm working a lot of.

Thanks,
Rodrigo.
rodrer
phpList newbie
 
Posts: 4
Joined: 1:06pm, Wed 28 Jan, 2009

Re: Sending Using Multiple SMTP Servers Simultaneously

Postby jimbo » 6:05pm, Thu 23 Sep, 2010

rodrer wrote:$phpmailer_smtphost_1 = 'domain.com';
$phpmailer_smtpuser_1 = 'login';
$phpmailer_smtppassword_1 = 'password';
#
$phpmailer_smtphost_2 = 'IP.IP.IP.IP';
$phpmailer_smtpuser_2 = 'login';
$phpmailer_smtppassword_2 = 'password';
#
$phpmailer_smtphost_3 = 'smtp.domain.com';
$phpmailer_smtpuser_3 = 'login';
$phpmailer_smtppassword_3 = 'password';




I was wondering if the smtp host would be the typical:
Code: Select all
mail.domain.com #like in outlook express / live mail

or
Code: Select all
domain.com

or maybe even
Code: Select all
localhost


Thanks for any assistance here.
jimbo
PL Nut
 
Posts: 15
Joined: 7:12pm, Wed 15 Sep, 2010

Re: Sending Using Multiple SMTP Servers Simultaneously

Postby cotoneal » 1:56pm, Wed 02 Feb, 2011

@rodrer: Well!! your solution works really well. However do you have made some modifications to manage better the queue processing?
cotoneal
phpLister
 
Posts: 7
Joined: 5:20pm, Thu 18 Nov, 2010

Re: Sending Using Multiple SMTP Servers Simultaneously

Postby miaminice » 5:28pm, Wed 11 May, 2011

When I set my config.php to use PHPMailer and set define("PHPMAILER",1);, I've noticed that most of my emails weren't being sent. The same is the case when I define PHPMailer to 0 and instead use my SMTP settings to send via Gmail.

I continued to have problems sending to my 2,700 mailing list even after reducing the size of my batch emails to define("MAILQUEUE_BATCH_SIZE",100); define("MAILQUEUE_BATCH_PERIOD",1);. I also experimented with other batch sizes, but it made no different.

Since I'm on a shared hosting and not on a dedicated server, my hosting has a daily limit of 100 emails per hour, which is probably why using PHPMAILER doesn't deliver all of my messages when my batch size is more than 100 per hour. Since my mailing list is 2,700 I wouldn't want to use a batch of 100/hr because it would take more than 24 hours to deliver my messages.

As an alternative, Gmail provides a daily limit of 500 emails per day when using their SMTP. However, using this option would take me 5 1/5 days to send all 2,700 messages.

So, what are my other options to deliver all my emails in a timely manner? Do you recommend that I use a 3rd party SMTP service that can bypass my hosting's & Gmail's SMTP and send more than the quota will allow? If so, which SMTP services do you recommend?
miaminice
phpLister
 
Posts: 6
Joined: 5:24pm, Tue 26 Apr, 2011

Re: Sending Using Multiple SMTP Servers Simultaneously

Postby BasicPro » 11:51pm, Mon 26 Sep, 2011

Hi,

I'm trying to use this feature rodrer posted but it's not working for me.

Do I have to just replace the existing /admin/class.phplistmailer.php for this code rodrer posted without any modifications?
That's what I did and results in a blank page when I try to access phplist.

I DID modify the config.php file as he explains but the problem resides in the class.phplistmailer.php
Do I have to modify the code he posted with some values? I really can't understand the comments in class.phplistmailer.php and they might explain what (and how) I should modify the code.
It seems like cotoneal could make this work, how did you do it? in which version of phplist? Any tips?

I am using right now version 2.10.12, this feature would really enhance the power of phplists.

Any tip would be apreciated!

EDIT: I did now understand how to do it, I replaced just the code rodrer posted and continued the normal class.phplistmailer.php after the ... (I'm a bit stupid sometimes)
It's working now but looking at the event log I don't understand why It works like that. I thought it would be sending in batches of x and using one smtp server on each batch. This would make the script faster cause it's a little bit slow (I was sending at 2600p/h and now 1300).
BasicPro
phpList newbie
 
Posts: 1
Joined: 11:44pm, Mon 26 Sep, 2011

Re: Sending Using Multiple SMTP Servers Simultaneously

Postby edenacom » 12:07pm, Sat 15 Oct, 2011

Thank you for this information. It was very useful for me!
edenacom
phpList newbie
 
Posts: 1
Joined: 11:57am, Sat 15 Oct, 2011

Re: Sending Using Multiple SMTP Servers Simultaneously

Postby sirkubax » 12:15pm, Tue 03 Jul, 2012

The problem with this solutions is that every SMTP connection must wait the end of the prior connection to SMTP to try to send emails again, I'm trying to make some changes on the file /admin/processqueue.php to create some kind of MULTI_THREAD without the use of SO resources, just using PHP.

I'm working on this issue and as so possible I'll put it here.
Excuse me but I'm working a lot of.


Hi,

Did you manage to send message without delay?
I need to use 3 smtp servers at the same time to send my mail list in reasonable time...
sirkubax
phpList newbie
 
Posts: 1
Joined: 12:13pm, Tue 03 Jul, 2012

Re: Sending Using Multiple SMTP Servers Simultaneously

Postby aunpixel » 7:33pm, Tue 16 Oct, 2012

Hi,

Did you manage to send message without delay?

Thanks for your answer !

Martin
aunpixel
phpList newbie
 
Posts: 1
Joined: 7:14pm, Tue 16 Oct, 2012

Re: Sending Using Multiple SMTP Servers Simultaneously

Postby trempest » 4:58pm, Sun 27 Apr, 2014

Hi! Bringing up an old thread here.

I'm just trying out multi SMTP and have not changed anything in class.phpmailer.php file but only in the config file.

I specified three working smtp servers separated by ; in PHPMAILERHOST along with port, TLS, user and password and it does work.

What im not sure is if it actually uses the three smtp servers because I created 5 campaigns from a single user and when i processed the queue I only see traffic on the postfix logs on one f the three smtp servers. two others are quiet.

I'm using 3.05 by the way and I really appreciate some guidance here. If you could, please shared with me the actual files you have that gets multi smtp working.

My email address is <Removed by Mod. Never post your email address in the clear in any forum to help avoid spam bot harvesting>

Thanks in advance to anyone who could help get this load off my server and my mind!
trempest
phpList newbie
 
Posts: 3
Joined: 4:03am, Fri 21 Mar, 2014

Next

Return to Advanced Answers, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 1 guest

cron