From 3fe2db6c8dfc012af796f467635f817f5ee54a6d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 29 Nov 2014 13:50:41 +0100 Subject: [PATCH] Try to find a solution to fight against spam sending from dolibarr when phpmail is set. No time to find a better solution so i add just a hidden option to disable phpmail function. --- htdocs/comm/mailing/card.php | 26 ++++++++++++++++++++++---- htdocs/langs/en_US/mails.lang | 5 ++++- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 678ea8f622d..ef9f29815c4 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -94,6 +94,13 @@ $object->substitutionarrayfortest=array( //,'__PERSONALIZED__' => 'TESTPersonalized' // Not used yet ); +// List of sending methods +$listofmethods=array(); +$listofmethods['mail']='PHP mail function'; +//$listofmethods['simplemail']='Simplemail class'; +$listofmethods['smtps']='SMTP/SMTPS socket library'; + + /* * Actions @@ -741,10 +748,21 @@ else { // Define message to recommand from command line - // Pour des raisons de securite, on ne permet pas cette fonction via l'IHM, - // on affiche donc juste un message + $sendingmode=$conf->global->MAIN_MAIL_SENDMODE; + if (empty($sendingmode)) $sendingmode='mail'; // If not defined, we use php mail function - if (empty($conf->global->MAILING_LIMIT_SENDBYWEB)) + if (! empty($conf->global->MAILING_NO_USING_PHPMAIL) && $sendingmode == 'mail') + { + // EMailing feature may be a spam problem, so when you host several users/instance, having this option may force each user to use their own SMTP agent. + // You ensure that every user is using its own SMTP server. + $linktoadminemailbefore=''; + $linktoadminemailend=''; + setEventMessage($langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]), 'warnings'); + setEventMessage($langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']), 'warnings'); + if (! empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS)) setEventMessage($langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS), 'warnings'); + $_GET["action"]=''; + } + else if (empty($conf->global->MAILING_LIMIT_SENDBYWEB)) { // Pour des raisons de securite, on ne permet pas cette fonction via l'IHM, // on affiche donc juste un message @@ -764,7 +782,7 @@ else } $text.=$langs->trans('ConfirmSendingEmailing').'
'; $text.=$langs->trans('LimitSendingEmailing',$conf->global->MAILING_LIMIT_SENDBYWEB); - print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id,$langs->trans('SendMailing'),$text,'sendallconfirmed',$formquestion,'',1,260); + print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id,$langs->trans('SendMailing'),$text,'sendallconfirmed',$formquestion,'',1,270); } } diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index 44027b4cc20..6fffc35bb08 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -115,7 +115,7 @@ SentBy=Sent by MailingNeedCommand=For security reason, sending an emailing is better when performed from command line. If you have one, ask your server administrator to launch the following command to send the emailing to all recipients: MailingNeedCommand2=You can however send them online by adding parameter MAILING_LIMIT_SENDBYWEB with value of max number of emails you want to send by session. For this, go on Home - Setup - Other. ConfirmSendingEmailing=If you can't or prefer sending them with your www browser, please confirm you are sure you want to send emailing now from your browser ? -LimitSendingEmailing=Note: On line sending of emailings are limited for security and timeout reasons to %s recipients by sending session. +LimitSendingEmailing=Note: Sending of emailings from web interface is done in several times for security and timeout reasons, %s recipients at a time for each sending session. TargetsReset=Clear list ToClearAllRecipientsClickHere=Click here to clear the recipient list for this emailing ToAddRecipientsChooseHere=Add recipients by choosing from the lists @@ -136,3 +136,6 @@ SomeNotificationsWillBeSent=%s notifications will be sent by email AddNewNotification=Activate a new email notification target ListOfActiveNotifications=List all active email notification targets ListOfNotificationsDone=List all email notifications sent +MailSendSetupIs=Configuration of email sending has been setup to '%s'. This mode can't be used to send mass emailing. +MailSendSetupIs2=You must first go, with an admin account, into menu %sHome - Setup - EMails%s to change parameter '%s' to use mode '%s'. With this mode, you can enter setup of the SMTP server provided by your Internet Service Provider and use Mass emailing feature. +MailSendSetupIs3=If you have any questions on how to setup your SMTP server, you can ask to %s.