ElasticEmail - limited to 20 concurrent connections

Lakjin

Active Member
So I just learned that ElasticEmail limits every account to 20 concurrent connections, so setting PCTNL to over than a total of 20 connections results in limit rating. However, they told me that one API connection can send multiple emails at once, rather than one email per connection. Can MailWizz be updated to support this?
 

Lakjin

Active Member
Okay, so I looked at the ElasticEmail API. It looks like one API request can send the SAME email to multiple contacts, but not DIFFERENT emails to multiple contacts in the same API connection. If this is correct, then this isn't particularly helpful.

However, they also note that they limit 20 connections per IP address. So can MailWizz support rotating between IP addresses to get around this 20 connections limit?
 

Lakjin

Active Member
So here is a band-aid solution, until MailWizz adds a better one (note that this is a direct edit to the /apps/common/models/DeliveryServerElasticemailWebApi.php file, I do not know how to make this into an extension):

Code:
//$response = AppInitHelper::simpleCurlPost('https://api.elasticemail.com/v2/email/send', $postData, (int)$this->timeout);
			
				/* STUFF I ADDED START */
				$ch = curl_init('https://api.elasticemail.com/v2/email/send');
				curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
				curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, (int)$this->timeout);
				curl_setopt($ch, CURLOPT_TIMEOUT, (int)$this->timeout);
				curl_setopt($ch, CURLOPT_POST, true);
				curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
				curl_setopt($ch, CURLOPT_AUTOREFERER, true);
				curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
				curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
				curl_setopt($ch, CURLOPT_USERAGENT, 'MailWizz/' . MW_VERSION);

				if (ini_get('open_basedir') == '' && ini_get('safe_mode') != 'On') {
					curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
				}
				
				$ipAddress123 = array('xxx.xxx',
									'yyy.yyy',
									'zzz.zzz',
									'aaa.aaa',
									'bbb.bbb',
									'ccc.ccc');
				shuffle($ipAddress123);
				
				curl_setopt($ch, CURLOPT_INTERFACE, $ipAddress123[0]);

				$body        = curl_exec($ch);
				$curlCode    = curl_errno($ch);
				$curlMessage = curl_error($ch);
				$httpCode    = 200;
				
				if (!$curlCode && defined('CURLINFO_HTTP_CODE')) {
					$httpCode = (int)curl_getinfo($ch, CURLINFO_HTTP_CODE);
				}

				curl_close($ch);

				if ($curlCode !== 0) {
					$response = array('status' => 'error', 'message' => $curlMessage, 'error_code' => $curlCode, 'http_code' => $httpCode);
				}

				$response = array('status' => 'success', 'message' => $body, 'error_code' => 0, 'http_code' => $httpCode);
				/* STUFF I ADDED END */
 
Top