26 require
'../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
31 $langs->loadLangs(array(
"companies",
"products",
"admin",
"mails",
"other",
"errors"));
33 $action =
GETPOST(
'action',
'aZ09');
34 $cancel =
GETPOST(
'cancel',
'aZ09');
38 $usersignature = $user->signature;
41 if ($action ==
'test' || $action ==
'send')
46 $substitutionarrayfortest = array(
47 '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT,
48 '__ID__' =>
'RecipientIdRecord',
50 '__CHECK_READ__' => (is_object($object) && is_object($object->thirdparty)) ?
'<img src="'.DOL_MAIN_URL_ROOT.
'/public/emailing/mailing-read.php?tag='.$object->thirdparty->tag.
'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).
'" width="1" height="1" style="width:1px;height:1px" border="0"/>' :
'',
51 '__USER_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature :
''),
52 '__LOGIN__' =>
'RecipientLogin',
53 '__LASTNAME__' =>
'RecipientLastname',
54 '__FIRSTNAME__' =>
'RecipientFirstname',
55 '__ADDRESS__'=>
'RecipientAddress',
56 '__ZIP__'=>
'RecipientZip',
57 '__TOWN_'=>
'RecipientTown',
58 '__COUNTRY__'=>
'RecipientCountry'
68 if ($action ==
'update' && !$cancel)
70 if (!$error && !
GETPOST(
"MAIN_MAIL_EMAIL_FROM",
'alphanohtml')) {
72 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"MAIN_MAIL_EMAIL_FROM")), null,
'errors');
77 setEventMessages($langs->trans(
"ErrorBadEMail",
GETPOST(
"MAIN_MAIL_EMAIL_FROM",
'alphanohtml')), null,
'errors');
82 dolibarr_set_const($db,
"MAIN_DISABLE_ALL_MAILS",
GETPOST(
"MAIN_DISABLE_ALL_MAILS",
'int'),
'chaine', 0,
'', $conf->entity);
83 dolibarr_set_const($db,
"MAIN_MAIL_FORCE_SENDTO",
GETPOST(
"MAIN_MAIL_FORCE_SENDTO",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
84 dolibarr_set_const($db,
"MAIN_MAIL_ENABLED_USER_DEST_SELECT",
GETPOST(
"MAIN_MAIL_ENABLED_USER_DEST_SELECT",
'int'),
'chaine', 0,
'', $conf->entity);
88 dolibarr_set_const($db,
"MAIN_MAIL_SMTP_SERVER",
GETPOST(
"MAIN_MAIL_SMTP_SERVER",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
89 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_ID",
GETPOST(
"MAIN_MAIL_SMTPS_ID",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
92 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_STARTTLS",
GETPOST(
"MAIN_MAIL_EMAIL_STARTTLS",
'int'),
'chaine', 0,
'', $conf->entity);
93 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED",
GETPOST(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED",
'int'),
'chaine', 0,
'', $conf->entity);
95 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_DKIM_ENABLED",
GETPOST(
"MAIN_MAIL_EMAIL_DKIM_ENABLED",
'int'),
'chaine', 0,
'', $conf->entity);
96 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_DKIM_DOMAIN",
GETPOST(
"MAIN_MAIL_EMAIL_DKIM_DOMAIN",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
97 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_DKIM_SELECTOR",
GETPOST(
"MAIN_MAIL_EMAIL_DKIM_SELECTOR",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
98 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY",
GETPOST(
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
100 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_FROM",
GETPOST(
"MAIN_MAIL_EMAIL_FROM",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
101 dolibarr_set_const($db,
"MAIN_MAIL_ERRORS_TO",
GETPOST(
"MAIN_MAIL_ERRORS_TO",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
102 dolibarr_set_const($db,
"MAIN_MAIL_AUTOCOPY_TO",
GETPOST(
"MAIN_MAIL_AUTOCOPY_TO",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
103 dolibarr_set_const($db,
'MAIN_MAIL_DEFAULT_FROMTYPE',
GETPOST(
'MAIN_MAIL_DEFAULT_FROMTYPE',
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
105 header(
"Location: ".
$_SERVER[
"PHP_SELF"].
"?mainmenu=home&leftmenu=setup");
113 $actiontypecode =
'';
114 $triggersendname =
'';
116 $mode =
'emailfortest';
117 $trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
119 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
121 if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'test') $action =
'test';
122 if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'testhtml') $action =
'testhtml';
131 $form =
new Form($db);
134 if (preg_match(
'/^win/i', PHP_OS)) {
137 if (preg_match(
'/^mac/i', PHP_OS)) {
141 if (empty($conf->global->MAIN_MAIL_SENDMODE)) $conf->global->MAIN_MAIL_SENDMODE =
'mail';
142 $port = !empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT : ini_get(
'smtp_port');
143 if (!$port) $port = 25;
144 $server = !empty($conf->global->MAIN_MAIL_SMTP_SERVER) ? $conf->global->MAIN_MAIL_SMTP_SERVER : ini_get(
'SMTP');
145 if (!$server) $server =
'127.0.0.1';
148 $wikihelp =
'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails';
156 $listofmethods = array();
157 $listofmethods[
'mail'] =
'PHP mail function';
158 $listofmethods[
'smtps'] =
'SMTP/SMTPS socket library';
159 if (version_compare(phpversion(),
'7.0',
'>=')) $listofmethods[
'swiftmailer'] =
'Swift Mailer socket library';
162 if ($action ==
'edit')
164 if ($conf->use_javascript_ajax)
166 print "\n".
'<script type="text/javascript" language="javascript">';
167 print 'jQuery(document).ready(function () {
168 function initfields()
170 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'mail\')
172 console.log("I choose php mail mode");
173 jQuery(".drag").hide();
174 jQuery("#MAIN_MAIL_EMAIL_TLS").val(0);
175 jQuery("#MAIN_MAIL_EMAIL_TLS").prop("disabled", true);
176 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(0);
177 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").prop("disabled", true);
178 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
179 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").prop("disabled", true);
180 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val(0);
181 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").prop("disabled", true);
182 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").prop("disabled", true);
183 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").prop("disabled", true);
184 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").prop("disabled", true);
185 jQuery(".smtp_method").hide();
186 jQuery(".dkim").hide();
191 jQuery("#MAIN_MAIL_SMTP_SERVER").hide();
192 jQuery("#MAIN_MAIL_SMTP_PORT").hide();
193 jQuery("#smtp_server_mess").show();
194 jQuery("#smtp_port_mess").show();';
197 jQuery("#MAIN_MAIL_SMTP_SERVER").prop("disabled", true);
198 jQuery("#MAIN_MAIL_SMTP_PORT").prop("disabled", true);
199 jQuery("#smtp_server_mess").hide();
200 jQuery("#smtp_port_mess").hide();';
204 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'smtps\')
206 console.log("I choose smtps mode");
207 jQuery(".drag").show();
208 jQuery("#MAIN_MAIL_EMAIL_TLS").val('.$conf->global->MAIN_MAIL_EMAIL_TLS.
');
209 jQuery("#MAIN_MAIL_EMAIL_TLS").removeAttr("disabled");
210 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val('.$conf->global->MAIN_MAIL_EMAIL_STARTTLS.
');
211 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").removeAttr("disabled");
212 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val('.$conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED.
');
213 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").removeAttr("disabled");
214 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val(0);
215 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").prop("disabled", true);
216 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").prop("disabled", true);
217 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").prop("disabled", true);
218 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").prop("disabled", true);
219 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").hide();
220 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").hide();
221 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").hide();
222 jQuery("#MAIN_MAIL_SMTP_SERVER").removeAttr("disabled");
223 jQuery("#MAIN_MAIL_SMTP_PORT").removeAttr("disabled");
224 jQuery("#MAIN_MAIL_SMTP_SERVER").show();
225 jQuery("#MAIN_MAIL_SMTP_PORT").show();
226 jQuery("#smtp_server_mess").hide();
227 jQuery("#smtp_port_mess").hide();
228 jQuery(".smtp_method").show();
229 jQuery(".dkim").hide();
231 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\')
233 console.log("I choose swiftmailer mode");
234 jQuery(".drag").show();
235 jQuery("#MAIN_MAIL_EMAIL_TLS").val('.$conf->global->MAIN_MAIL_EMAIL_TLS.
');
236 jQuery("#MAIN_MAIL_EMAIL_TLS").removeAttr("disabled");
237 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val('.$conf->global->MAIN_MAIL_EMAIL_STARTTLS.
');
238 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").removeAttr("disabled");
239 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val('.$conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED.
');
240 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").removeAttr("disabled");
241 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val('.$conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED.
');
242 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").removeAttr("disabled");
243 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").removeAttr("disabled");
244 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").removeAttr("disabled");
245 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").removeAttr("disabled");
246 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").show();
247 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").show();
248 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").show();
249 jQuery("#MAIN_MAIL_SMTP_SERVER").removeAttr("disabled");
250 jQuery("#MAIN_MAIL_SMTP_PORT").removeAttr("disabled");
251 jQuery("#MAIN_MAIL_SMTP_SERVER").show();
252 jQuery("#MAIN_MAIL_SMTP_PORT").show();
253 jQuery("#smtp_server_mess").hide();
254 jQuery("#smtp_port_mess").hide();
255 jQuery(".smtp_method").show();
256 jQuery(".dkim").show();
260 jQuery("#MAIN_MAIL_SENDMODE").change(function() {
263 jQuery("#MAIN_MAIL_EMAIL_TLS").change(function() {
264 if (jQuery("#MAIN_MAIL_EMAIL_TLS").val() == 1)
265 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(0);
267 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
269 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").change(function() {
270 if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val() == 1)
271 jQuery("#MAIN_MAIL_EMAIL_TLS").val(0);
273 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
276 print '</script>'.
"\n";
279 print '<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
280 print '<input type="hidden" name="token" value="'.newToken().
'">';
281 print '<input type="hidden" name="action" value="update">';
285 print '<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
291 print '<table class="noborder centpercent">';
292 print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
295 print '<tr class="oddeven"><td>'.$langs->trans(
"MAIN_DISABLE_ALL_MAILS").
'</td><td>';
296 print $form->selectyesno(
'MAIN_DISABLE_ALL_MAILS', $conf->global->MAIN_DISABLE_ALL_MAILS, 1);
300 print '<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_FORCE_SENDTO").
'</td><td>';
301 print '<input class="flat" name="MAIN_MAIL_FORCE_SENDTO" size="32" value="'.(!empty($conf->global->MAIN_MAIL_FORCE_SENDTO) ? $conf->global->MAIN_MAIL_FORCE_SENDTO :
'').
'" />';
308 print
'<table class="noborder centpercent">';
309 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td></td></tr>';
312 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
315 if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity))
317 print $form->selectarray(
'MAIN_MAIL_SENDMODE', $listofmethods, $conf->global->MAIN_MAIL_SENDMODE);
319 $text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE];
320 if (empty($text)) $text = $langs->trans(
"Undefined");
321 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
322 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
323 print
'<input type="hidden" name="MAIN_MAIL_SENDMODE" value="'.$conf->global->MAIN_MAIL_SENDMODE.
'">';
328 print
'<tr class="oddeven">';
329 if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE ==
'mail') {
331 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
333 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
337 $mainserver = (!empty($conf->global->MAIN_MAIL_SMTP_SERVER) ? $conf->global->MAIN_MAIL_SMTP_SERVER :
'');
338 $smtpserver = ini_get(
'SMTP') ?ini_get(
'SMTP') : $langs->transnoentities(
"Undefined");
339 if ($linuxlike) print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
340 else print $langs->trans(
"MAIN_MAIL_SMTP_SERVER", $smtpserver);
343 if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity))
345 print
'<input class="flat minwidth300" id="MAIN_MAIL_SMTP_SERVER" name="MAIN_MAIL_SMTP_SERVER" value="'.$mainserver.
'" autocomplete="off">';
346 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_sav" name="MAIN_MAIL_SMTP_SERVER_sav" value="'.$mainserver.
'">';
347 print
'<span id="smtp_server_mess" class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
348 print
' <span class="opacitymedium smtp_method">'.$langs->trans(
"SeeLinkToOnlineDocumentation").
'</span>';
350 $text = !empty($mainserver) ? $mainserver : $smtpserver;
351 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
352 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
353 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER" name="MAIN_MAIL_SMTP_SERVER" value="'.$mainserver.
'">';
360 print
'<tr class="oddeven"><td>';
361 if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE ==
'mail')
363 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
365 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
367 $mainport = (!empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT :
'');
368 $smtpport = ini_get(
'smtp_port') ?ini_get(
'smtp_port') : $langs->transnoentities(
"Undefined");
369 if ($linuxlike) print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
370 else print $langs->trans(
"MAIN_MAIL_SMTP_PORT", $smtpport);
373 if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity))
375 print
'<input class="flat" id="MAIN_MAIL_SMTP_PORT" name="MAIN_MAIL_SMTP_PORT" size="3" value="'.$mainport.
'">';
376 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT_sav" name="MAIN_MAIL_SMTP_PORT_sav" value="'.$mainport.
'">';
377 print
'<span id="smtp_port_mess" class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
379 $text = (!empty($mainport) ? $mainport : $smtpport);
380 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
381 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
382 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT" name="MAIN_MAIL_SMTP_PORT" value="'.$mainport.
'">';
388 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array(
'smtps',
'swiftmailer'))))
390 $mainstmpid = (!empty($conf->global->MAIN_MAIL_SMTPS_ID) ? $conf->global->MAIN_MAIL_SMTPS_ID :
'');
391 print
'<tr class="drag drop oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>';
393 if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity))
395 print
'<input class="flat" name="MAIN_MAIL_SMTPS_ID" size="32" value="'.$mainstmpid.
'">';
397 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
398 print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_ID, $htmltext, 1,
'superadmin');
399 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_ID" value="'.$mainstmpid.
'">';
405 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array(
'smtps',
'swiftmailer'))))
407 $mainsmtppw = (!empty($conf->global->MAIN_MAIL_SMTPS_PW) ? $conf->global->MAIN_MAIL_SMTPS_PW :
'');
408 print
'<tr class="drag drop oddeven"><td>';
409 print $form->textwithpicto($langs->trans(
"MAIN_MAIL_SMTPS_PW"), $langs->trans(
"WithGMailYouCanCreateADedicatedPassword"));
412 if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity))
414 print
'<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW" size="32" value="'.$mainsmtppw.
'" autocomplete="off">';
416 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
417 print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_PW, $htmltext, 1,
'superadmin');
418 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_PW" value="'.$mainsmtppw.
'">';
424 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
425 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array(
'smtps',
'swiftmailer'))))
427 if (function_exists(
'openssl_open'))
429 print $form->selectyesno(
'MAIN_MAIL_EMAIL_TLS', (!empty($conf->global->MAIN_MAIL_EMAIL_TLS) ? $conf->global->MAIN_MAIL_EMAIL_TLS : 0), 1);
430 }
else print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
431 }
else print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
435 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
436 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array(
'smtps',
'swiftmailer'))))
438 if (function_exists(
'openssl_open'))
440 print $form->selectyesno(
'MAIN_MAIL_EMAIL_STARTTLS', (!empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS) ? $conf->global->MAIN_MAIL_EMAIL_STARTTLS : 0), 1);
441 }
else print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
442 }
else print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
446 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
447 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array(
'smtps',
'swiftmailer'))))
449 if (function_exists(
'openssl_open'))
451 print $form->selectyesno(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED', (!empty($conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED) ? $conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED : 0), 1);
452 }
else print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
453 }
else print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
457 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_ENABLED").
'</td><td>';
458 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array(
'swiftmailer'))))
460 if (function_exists(
'openssl_open'))
462 print $form->selectyesno(
'MAIN_MAIL_EMAIL_DKIM_ENABLED', (!empty($conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED) ? $conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED : 0), 1);
463 }
else print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
464 }
else print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
468 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_DOMAIN").
'</td>';
469 print
'<td><input class="flat" id="MAIN_MAIL_EMAIL_DKIM_DOMAIN" name="MAIN_MAIL_EMAIL_DKIM_DOMAIN" size="32" value="'.(!empty($conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN) ? $conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN :
'');
470 print
'"></td></tr>';
473 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_SELECTOR").
'</td>';
474 print
'<td><input class="flat" id="MAIN_MAIL_EMAIL_DKIM_SELECTOR" name="MAIN_MAIL_EMAIL_DKIM_SELECTOR" size="32" value="'.(!empty($conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR) ? $conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR :
'');
475 print
'"></td></tr>';
478 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").
'</td>';
479 print
'<td><textarea id="MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY" name="MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY" rows="15" cols="100">'.(!empty($conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY) ? $conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY :
'').
'</textarea>';
486 print
'<table class="noborder centpercent">';
487 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"OtherOptions").
'</td><td></td></tr>';
490 print
'<tr class="oddeven"><td class="fieldrequired">'.$langs->trans(
"MAIN_MAIL_EMAIL_FROM", ini_get(
'sendmail_from') ?ini_get(
'sendmail_from') : $langs->transnoentities(
"Undefined")).
'</td>';
491 print
'<td><input class="flat minwidth200" name="MAIN_MAIL_EMAIL_FROM" value="'.(!empty($conf->global->MAIN_MAIL_EMAIL_FROM) ? $conf->global->MAIN_MAIL_EMAIL_FROM :
'');
492 print
'"></td></tr>';
496 $liste[
'user'] = $langs->trans(
'UserEmail');
497 $liste[
'company'] = $langs->trans(
'CompanyEmail').
' ('.(empty($conf->global->MAIN_INFO_SOCIETE_MAIL) ? $langs->trans(
"NotDefined") : $conf->global->MAIN_INFO_SOCIETE_MAIL).
')';
499 print
'<tr class="oddeven"><td>'.$langs->trans(
'MAIN_MAIL_DEFAULT_FROMTYPE').
'</td><td>';
500 print $form->selectarray(
'MAIN_MAIL_DEFAULT_FROMTYPE', $liste, $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE, 0);
504 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ERRORS_TO").
'</td>';
505 print
'<td><input class="flat" name="MAIN_MAIL_ERRORS_TO" size="32" value="'.(!empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO :
'');
506 print
'"></td></tr>';
509 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_AUTOCOPY_TO").
'</td>';
510 print
'<td><input class="flat" name="MAIN_MAIL_AUTOCOPY_TO" size="32" value="'.(!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO) ? $conf->global->MAIN_MAIL_AUTOCOPY_TO :
'');
511 print
'"></td></tr>';
514 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ENABLED_USER_DEST_SELECT").
'</td><td>';
515 print $form->selectyesno(
'MAIN_MAIL_ENABLED_USER_DEST_SELECT', $conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT, 1);
522 print
'<br><div class="center">';
523 print
'<input class="button button-save" type="submit" name="save" value="'.$langs->trans(
"Save").
'">';
524 print
' ';
525 print
'<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
532 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
535 print
'<div class="div-table-responsive-no-min">';
536 print
'<table class="noborder centpercent">';
537 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
540 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_DISABLE_ALL_MAILS").
'</td><td>'.
yn($conf->global->MAIN_DISABLE_ALL_MAILS);
541 if (!empty($conf->global->MAIN_DISABLE_ALL_MAILS)) print
img_warning($langs->trans(
"Disabled"));
544 if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
546 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_FORCE_SENDTO").
'</td><td>'.$conf->global->MAIN_MAIL_FORCE_SENDTO;
547 if (!empty($conf->global->MAIN_MAIL_FORCE_SENDTO))
550 else print
img_warning($langs->trans(
"RecipientEmailsWillBeReplacedWithThisValue"));
558 if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
561 print
'<div class="div-table-responsive-no-min">';
562 print
'<table class="noborder centpercent">';
563 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td></td></tr>';
566 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
567 $text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE];
568 if (empty($text)) $text = $langs->trans(
"Undefined").img_warning();
571 if ($conf->global->MAIN_MAIL_SENDMODE ==
'mail' && empty($conf->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) {
572 print $form->textwithpicto(
'', $langs->trans(
"WarningPHPMail").
'<br>'.$langs->trans(
"WarningPHPMailA").
'<br>'.$langs->trans(
"WarningPHPMailB").
'<br>'.$langs->trans(
"WarningPHPMailC").
'<br><br>'.$langs->trans(
"WarningPHPMailD"), 1,
'warning');
578 if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE ==
'mail'))
580 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").
'</td><td><span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span></td></tr>';
582 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTP_SERVER", ini_get(
'SMTP') ?ini_get(
'SMTP') : $langs->transnoentities(
"Undefined")).
'</td><td>'.(!empty($conf->global->MAIN_MAIL_SMTP_SERVER) ? $conf->global->MAIN_MAIL_SMTP_SERVER :
'').
'</td></tr>';
586 if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE ==
'mail'))
588 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").
'</td><td><span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span></td></tr>';
590 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTP_PORT", ini_get(
'smtp_port') ?ini_get(
'smtp_port') : $langs->transnoentities(
"Undefined")).
'</td><td>'.(!empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT :
'').
'</td></tr>';
594 if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array(
'smtps',
'swiftmailer')))
596 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>'.$conf->global->MAIN_MAIL_SMTPS_ID.
'</td></tr>';
600 if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array(
'smtps',
'swiftmailer')))
602 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_PW").
'</td><td>'.preg_replace(
'/./',
'*', $conf->global->MAIN_MAIL_SMTPS_PW).
'</td></tr>';
606 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
607 if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array(
'smtps',
'swiftmailer')))
609 if (function_exists(
'openssl_open'))
611 print
yn($conf->global->MAIN_MAIL_EMAIL_TLS);
612 }
else print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
613 }
else print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
617 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
618 if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array(
'smtps',
'swiftmailer')))
620 if (function_exists(
'openssl_open'))
622 print
yn($conf->global->MAIN_MAIL_EMAIL_STARTTLS);
623 }
else print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
624 }
else print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
628 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
629 if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array(
'smtps',
'swiftmailer')))
631 if (function_exists(
'openssl_open'))
633 print
yn($conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED);
634 }
else print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
635 }
else print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
639 if ($conf->global->MAIN_MAIL_SENDMODE ==
'swiftmailer')
642 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_ENABLED").
'</td><td>';
643 if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array(
'swiftmailer')))
645 if (function_exists(
'openssl_open'))
647 print
yn($conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED);
648 }
else print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
649 }
else print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
653 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_DOMAIN").
'</td>';
654 print
'<td>'.$conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN;
658 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_SELECTOR").
'</td>';
659 print
'<td>'.$conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR;
663 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").
'</td>';
664 print
'<td>'.$conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY;
671 if ($conf->global->MAIN_MAIL_SENDMODE ==
'mail' && empty($conf->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) {
672 print
info_admin($langs->trans(
"WarningPHPMail").
'<br>'.$langs->trans(
"WarningPHPMailA").
'<br>'.$langs->trans(
"WarningPHPMailB").
'<br>'.$langs->trans(
"WarningPHPMailC").
'<br><br>'.$langs->trans(
"WarningPHPMailD"), 0, 0,
'warning');
677 print
'<div class="div-table-responsive-no-min">';
678 print
'<table class="noborder centpercent">';
679 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"OtherOptions").
'</td><td></td></tr>';
682 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_FROM", ini_get(
'sendmail_from') ?ini_get(
'sendmail_from') : $langs->transnoentities(
"Undefined")).
'</td>';
683 print
'<td>'.$conf->global->MAIN_MAIL_EMAIL_FROM;
684 if (empty($conf->global->MAIN_MAIL_EMAIL_FROM)) print
img_warning($langs->trans(
"Mandatory"));
690 $liste['
user'] = $langs->trans('UserEmail');
691 $liste['company'] = $langs->trans('CompanyEmail').' ('.(empty($conf->global->MAIN_INFO_SOCIETE_MAIL) ? $langs->trans("NotDefined") : $conf->global->MAIN_INFO_SOCIETE_MAIL).')';
692 $sql = 'SELECT
rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile';
693 $sql .= ' WHERE active = 1 AND (private = 0 OR private = '.$user->
id.')';
694 $resql = $db->query($sql);
697 $num = $db->num_rows($resql);
701 $obj = $db->fetch_object($resql);
704 $liste[
'senderprofile_'.$obj->rowid] = $obj->label.
' <'.$obj->email.
'>';
710 print
'<tr class="oddeven"><td>'.$langs->trans(
'MAIN_MAIL_DEFAULT_FROMTYPE').
'</td>';
712 if ($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE ===
'robot')
714 print $langs->trans(
'RobotEmail');
715 } elseif ($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE ===
'user')
717 print $langs->trans(
'UserEmail');
718 } elseif ($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE ===
'company')
722 $id = preg_replace(
'/senderprofile_/',
'', $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE);
725 include_once DOL_DOCUMENT_ROOT.
'/core/class/emailsenderprofile.class.php';
727 $emailsenderprofile->fetch($id);
728 print $emailsenderprofile->label.
' '.
dol_escape_htmltag(
'<'.$emailsenderprofile->email.
'>');
734 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ERRORS_TO").
'</td>';
735 print
'<td>'.$conf->global->MAIN_MAIL_ERRORS_TO;
736 if (!empty($conf->global->MAIN_MAIL_ERRORS_TO) && !
isValidEmail($conf->global->MAIN_MAIL_ERRORS_TO)) print
img_warning($langs->trans(
"ErrorBadEMail"));
740 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_AUTOCOPY_TO").
'</td>';
742 if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO))
744 print $conf->global->MAIN_MAIL_AUTOCOPY_TO;
752 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ENABLED_USER_DEST_SELECT").
'</td><td>'.
yn($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT).
'</td></tr>';
762 print
'<div class="tabsAction">';
764 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit">'.$langs->trans(
"Modify").
'</a>';
766 if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
767 if ($conf->global->MAIN_MAIL_SENDMODE !=
'mail' || !$linuxlike)
769 if (function_exists(
'fsockopen') && $port && $server)
771 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testconnect&date='.
dol_now().
'#formmailaftertstconnect">'.$langs->trans(
"DoTestServerAvailability").
'</a>';
774 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"FeatureNotAvailableOnLinux").
'">'.$langs->trans(
"DoTestServerAvailability").
'</a>';
777 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=test&mode=init#formmailbeforetitle">'.$langs->trans(
"DoTestSend").
'</a>';
779 if (!empty($conf->fckeditor->enabled))
781 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testhtml&mode=init#formmailbeforetitle">'.$langs->trans(
"DoTestSendHTML").
'</a>';
788 if ($conf->global->MAIN_MAIL_SENDMODE ==
'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA))
801 print
info_admin($langs->trans(
"SendmailOptionMayHurtBuggedMTA"));
804 if (!in_array($action, array(
'testconnect',
'test',
'testhtml')))
807 if ($conf->global->MAIN_MAIL_SENDMODE ==
'mail')
812 if ($conf->global->MAIN_MAIL_SENDMODE ==
'mail')
814 if (!empty($conf->global->MAIN_EXTERNAL_MAIL_SPF_STRING_TO_ADD))
817 $text .= ($text ?
'<br><br>' :
'').$langs->trans(
"WarningPHPMailSPF", $conf->global->MAIN_EXTERNAL_MAIL_SPF_STRING_TO_ADD);
820 if (!empty($conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS))
823 $text .= ($text ?
'<br><br>' :
'').$langs->trans(
"WarningPHPMailSPF", $conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS);
827 if (!empty($conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS))
831 $text .= ($text ?
'<br><br>' :
'').$langs->trans(
"WarningPHPMail2", $conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS);
833 if (!empty($conf->global->MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD))
836 $text .= ($text ?
'<br><br>' :
'').$langs->trans(
"WarningPHPMailSPF", $conf->global->MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD);
845 if ($action ==
'testconnect')
847 print
'<div id="formmailaftertstconnect" name="formmailaftertstconnect"></div>';
850 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
851 $mail =
new CMailFile(
'',
'',
'',
'', array(), array(), array(),
'',
'', 0,
'',
'',
'',
'', $trackid, $sendcontext);
852 $result = $mail->check_server_port($server, $port);
853 if ($result) print
'<div class="ok">'.$langs->trans(
"ServerAvailableOnIPOrPort", $server, $port).
'</div>';
855 $errormsg = $langs->trans(
"ServerNotAvailableOnIPOrPort", $server, $port);
858 $errormsg .=
' - '.$mail->error;
868 if ($action ==
'test' || $action ==
'testhtml')
870 print
'<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
871 print
load_fiche_titre($action ==
'testhtml' ? $langs->trans(
"DoTestSendHTML") : $langs->trans(
"DoTestSend"));
876 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
878 $formmail->trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
879 $formmail->fromname = (
GETPOSTISSET(
'fromname') ? $_POST[
'fromname'] : $conf->global->MAIN_MAIL_EMAIL_FROM);
880 $formmail->frommail = (
GETPOSTISSET(
'frommail') ? $_POST[
'frommail'] : $conf->global->MAIN_MAIL_EMAIL_FROM);
881 $formmail->fromid = $user->id;
882 $formmail->fromalsorobot = 1;
883 $formmail->fromtype = (
GETPOSTISSET(
'fromtype') ?
GETPOST(
'fromtype',
'aZ09') : (!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE) ? $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE :
'user'));
884 $formmail->withfromreadonly = 1;
885 $formmail->withsubstit = 1;
886 $formmail->withfrom = 1;
887 $formmail->witherrorsto = 1;
888 $formmail->withto = (!empty($_POST[
'sendto']) ?
GETPOST(
'sendto',
'restricthtml') : ($user->email ? $user->email : 1));
889 $formmail->withtocc = (!empty($_POST[
'sendtocc']) ?
GETPOST(
'sendtocc',
'restricthtml') : 1);
890 $formmail->withtoccc = (!empty($_POST[
'sendtoccc']) ?
GETPOST(
'sendtoccc',
'restricthtml') : 1);
891 $formmail->withtopic = (
GETPOSTISSET(
'subject') ?
GETPOST(
'subject') : $langs->trans(
"Test"));
892 $formmail->withtopicreadonly = 0;
893 $formmail->withfile = 2;
894 $formmail->withbody = (
GETPOSTISSET(
'message') ?
GETPOST(
'message',
'restricthtml') : ($action ==
'testhtml' ? $langs->transnoentities(
"PredefinedMailTestHtml") : $langs->transnoentities(
"PredefinedMailTest")));
895 $formmail->withbodyreadonly = 0;
896 $formmail->withcancel = 1;
897 $formmail->withdeliveryreceipt = 1;
898 $formmail->withfckeditor = ($action ==
'testhtml' ? 1 : 0);
899 $formmail->ckeditortoolbar =
'dolibarr_mailings';
901 $formmail->substit = $substitutionarrayfortest;
903 $formmail->param[
"action"] =
"send";
904 $formmail->param[
"models"] =
"body";
905 $formmail->param[
"mailid"] = 0;
906 $formmail->param[
"returnurl"] =
$_SERVER[
"PHP_SELF"];
909 if (
GETPOST(
"mode",
"aZ09") ==
'init')
911 $formmail->clear_attached_files();
914 print $formmail->get_form(
'addfile',
'removefile');
919 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsWillHaveMessageID").
': ';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto= 'UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
</td >< tdcolspan="3">< spanclass="opacitymedium"></span ></td ></tr >< trclass="liste_total"> CREANCES DETTES< tdcolspan="3"class="right"></td >< tdcolspan="3"class="right"></td ></tr > CREANCES DETTES RECETTES DEPENSES trips CREANCES DETTES Y m expensereport p date_valid Y m expensereport pe datep $db idate($date_start)."' AND $column < p rowid
email_admin_prepare_head()
Return array head with list of tabs to view object informations.
dol_now($mode= 'auto')
Return date for now.
dolibarr_set_const($db, $name, $value, $type= 'chaine', $visible=0, $note= '', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save"&&empty($cancel)) $wikihelp
View.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,$sendto,$replyto,$message,$filepath,$mimetype,$filename,$cc,$ccc,$deliveryreceipt,$msgishtml,$errors_to,$css,$trackid,$moreinheader,$sendcontext,$replyto); $mailfile->sendfile();.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Class for EmailSenderProfile.
isValidEmail($address, $acceptsupervisorkey=0)
Return true if email syntax is ok.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= '', $textfordropdown= '')
Show information for admin users or standard users.
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...