Browse Source

Added delay between mails in Newsletter module

Marcos García de La Fuente 10 years ago
parent
commit
fb186d6ef8

+ 1 - 0
ChangeLog

@@ -12,6 +12,7 @@ For users:
   MARGIN_PMP_AS_DEFAULT_BUY_PRICE to replace with first supplier price.
 - Introduce option MAIN_HTML_TITLE to start to control format of html title content.
 - Add extrafields on bank account cards.
+- Added delay between mails in Newsletter module
 
 For translators:
 - Update language files.

+ 9 - 0
htdocs/admin/mailing.php

@@ -48,11 +48,14 @@ if ($action == 'setvalue')
 	$mailerror = GETPOST('MAILING_EMAIL_ERRORSTO','alpha');
 	$checkread = GETPOST('value','alpha');
 	$checkread_key = GETPOST('MAILING_EMAIL_UNSUBSCRIBE_KEY','alpha');
+    $mailingdelay = GETPOST('MAILING_DELAY', 'int');
 
 	$res=dolibarr_set_const($db, "MAILING_EMAIL_FROM",$mailfrom,'chaine',0,'',$conf->entity);
 	if (! $res > 0) $error++;
 	$res=dolibarr_set_const($db, "MAILING_EMAIL_ERRORSTO",$mailerror,'chaine',0,'',$conf->entity);
 	if (! $res > 0) $error++;
+	$res=dolibarr_set_const($db, "MAILING_DELAY",$mailingdelay,'chaine',0,'',$conf->entity);
+	if (! $res > 0) $error++;
 
 	// Create temporary encryption key if nedded
 	$res=dolibarr_set_const($db, "MAILING_EMAIL_UNSUBSCRIBE_KEY",$checkread_key,'chaine',0,'',$conf->entity);
@@ -124,6 +127,12 @@ print '<input size="32" type="text" name="MAILING_EMAIL_ERRORSTO" value="'.$conf
 if (!empty($conf->global->MAILING_EMAIL_ERRORSTO) && ! isValidEmail($conf->global->MAILING_EMAIL_ERRORSTO)) print ' '.img_warning($langs->trans("BadEMail"));
 print '</td></tr>';
 
+$var=!$var;
+print '<tr '.$bc[$var].'><td>';
+print $langs->trans("MailingDelay").'</td><td>';
+print '<input size="32" type="text" name="MAILING_DELAY" value="'.$conf->global->MAILING_DELAY.'">';
+print '</td></tr>';
+
 // Constant to add salt into the unsubscribe and check read tag.
 // It is also used as a security key parameter.
 $var=!$var;

+ 4 - 1
htdocs/comm/mailing/card.php

@@ -323,7 +323,10 @@ if ($action == 'sendallconfirmed' && $confirm == 'yes')
 							}
 						}
 
-
+                        if (!empty($conf->global->MAILING_DELAY)) {
+                            sleep($conf->global->MAILING_DELAY);
+                        }
+                        
 						//test if CHECK READ change statut prospect contact
 					}
 					else

+ 1 - 0
htdocs/langs/en_US/admin.lang

@@ -1393,6 +1393,7 @@ RSSUrlExample=An interesting RSS feed
 MailingSetup=EMailing module setup
 MailingEMailFrom=Sender EMail (From) for emails sent by emailing module
 MailingEMailError=Return EMail (Errors-to) for emails with errors
+MailingDelay=Seconds to wait after sending next message
 ##### Notification #####
 NotificationSetup=EMail notification module setup
 NotificationEMailFrom=Sender EMail (From) for emails sent for notifications

+ 5 - 0
scripts/emailings/mailing-send.php

@@ -245,6 +245,11 @@ if ($resql)
 										$error++;
 									}
 								}
+                                
+                                if (!empty($conf->global->MAILING_DELAY)) {
+                                    sleep($conf->global->MAILING_DELAY);
+                                }
+
 							}
 						}
 						else