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');
40 $usersignature = $user->signature;
43 if ($action ==
'test' || $action ==
'send') {
47 $substitutionarrayfortest = array(
48 '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT,
49 '__CHECK_READ__' => (!empty($object) && 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"/>' :
'',
50 '__USER_LOGIN__' => $user->login,
51 '__USER_EMAIL__' => $user->email,
52 '__USER_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature :
''),
53 '__ID__' =>
'RecipientIdRecord',
55 '__LASTNAME__' =>
'RecipientLastname',
56 '__FIRSTNAME__' =>
'RecipientFirstname',
57 '__ADDRESS__'=>
'RecipientAddress',
58 '__ZIP__'=>
'RecipientZip',
59 '__TOWN_'=>
'RecipientTown',
60 '__COUNTRY__'=>
'RecipientCountry'
70 if ($action ==
'update' && !$cancel) {
71 if (!$error && !
GETPOST(
"MAIN_MAIL_EMAIL_FROM",
'alphanohtml')) {
73 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"MAIN_MAIL_EMAIL_FROM")), null,
'errors');
78 setEventMessages($langs->trans(
"ErrorBadEMail",
GETPOST(
"MAIN_MAIL_EMAIL_FROM",
'alphanohtml')), null,
'errors');
83 dolibarr_set_const($db,
"MAIN_DISABLE_ALL_MAILS",
GETPOST(
"MAIN_DISABLE_ALL_MAILS",
'int'),
'chaine', 0,
'', $conf->entity);
84 dolibarr_set_const($db,
"MAIN_MAIL_FORCE_SENDTO",
GETPOST(
"MAIN_MAIL_FORCE_SENDTO",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
85 dolibarr_set_const($db,
"MAIN_MAIL_ENABLED_USER_DEST_SELECT",
GETPOST(
"MAIN_MAIL_ENABLED_USER_DEST_SELECT",
'int'),
'chaine', 0,
'', $conf->entity);
89 dolibarr_set_const($db,
"MAIN_MAIL_SMTP_SERVER",
GETPOST(
"MAIN_MAIL_SMTP_SERVER",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
90 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_ID",
GETPOST(
"MAIN_MAIL_SMTPS_ID",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
93 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_STARTTLS",
GETPOST(
"MAIN_MAIL_EMAIL_STARTTLS",
'int'),
'chaine', 0,
'', $conf->entity);
94 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED",
GETPOST(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED",
'int'),
'chaine', 0,
'', $conf->entity);
96 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_DKIM_ENABLED",
GETPOST(
"MAIN_MAIL_EMAIL_DKIM_ENABLED",
'int'),
'chaine', 0,
'', $conf->entity);
97 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_DKIM_DOMAIN",
GETPOST(
"MAIN_MAIL_EMAIL_DKIM_DOMAIN",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
98 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_DKIM_SELECTOR",
GETPOST(
"MAIN_MAIL_EMAIL_DKIM_SELECTOR",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
99 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY",
GETPOST(
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
101 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_FROM",
GETPOST(
"MAIN_MAIL_EMAIL_FROM",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
102 dolibarr_set_const($db,
"MAIN_MAIL_ERRORS_TO",
GETPOST(
"MAIN_MAIL_ERRORS_TO",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
103 dolibarr_set_const($db,
"MAIN_MAIL_AUTOCOPY_TO",
GETPOST(
"MAIN_MAIL_AUTOCOPY_TO",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
104 dolibarr_set_const($db,
'MAIN_MAIL_DEFAULT_FROMTYPE',
GETPOST(
'MAIN_MAIL_DEFAULT_FROMTYPE',
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
106 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?mainmenu=home&leftmenu=setup");
114 $actiontypecode =
'';
115 $triggersendname =
'';
117 $mode =
'emailfortest';
118 $trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
120 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
122 if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'test') {
125 if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'testhtml') {
126 $action =
'testhtml';
139 if (preg_match(
'/^win/i', PHP_OS)) {
142 if (preg_match(
'/^mac/i', PHP_OS)) {
146 if (empty($conf->global->MAIN_MAIL_SENDMODE)) {
147 $conf->global->MAIN_MAIL_SENDMODE =
'mail';
149 $port = !empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT : ini_get(
'smtp_port');
153 $server = !empty($conf->global->MAIN_MAIL_SMTP_SERVER) ? $conf->global->MAIN_MAIL_SMTP_SERVER : ini_get(
'SMTP');
155 $server =
'127.0.0.1';
159 $wikihelp =
'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails';
167 $listofmethods = array();
168 $listofmethods[
'mail'] =
'PHP mail function';
169 $listofmethods[
'smtps'] =
'SMTP/SMTPS socket library';
170 if (version_compare(phpversion(),
'7.0',
'>=')) {
171 $listofmethods[
'swiftmailer'] =
'Swift Mailer socket library';
175 if ($action ==
'edit') {
176 if ($conf->use_javascript_ajax) {
177 print
"\n".
'<script type="text/javascript">';
178 print
'jQuery(document).ready(function () {
179 function initfields()
181 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'mail\')
183 console.log("I choose php mail mode");
184 jQuery(".drag").hide();
185 jQuery("#MAIN_MAIL_EMAIL_TLS").val(0);
186 jQuery("#MAIN_MAIL_EMAIL_TLS").prop("disabled", true);
187 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(0);
188 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").prop("disabled", true);
189 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
190 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").prop("disabled", true);
191 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val(0);
192 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").prop("disabled", true);
193 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").prop("disabled", true);
194 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").prop("disabled", true);
195 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").prop("disabled", true);
196 jQuery(".smtp_method").hide();
197 jQuery(".dkim").hide();
201 jQuery("#MAIN_MAIL_SMTP_SERVER").hide();
202 jQuery("#MAIN_MAIL_SMTP_PORT").hide();
203 jQuery("#smtp_server_mess").show();
204 jQuery("#smtp_port_mess").show();';
207 jQuery("#MAIN_MAIL_SMTP_SERVER").prop("disabled", true);
208 jQuery("#MAIN_MAIL_SMTP_PORT").prop("disabled", true);
209 jQuery("#smtp_server_mess").hide();
210 jQuery("#smtp_port_mess").hide();';
214 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'smtps\')
216 console.log("I choose smtps mode");
217 jQuery(".drag").show();
218 jQuery("#MAIN_MAIL_EMAIL_TLS").val('.$conf->global->MAIN_MAIL_EMAIL_TLS.
');
219 jQuery("#MAIN_MAIL_EMAIL_TLS").removeAttr("disabled");
220 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val('.$conf->global->MAIN_MAIL_EMAIL_STARTTLS.
');
221 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").removeAttr("disabled");
222 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val('.$conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED.
');
223 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").removeAttr("disabled");
224 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val(0);
225 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").prop("disabled", true);
226 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").prop("disabled", true);
227 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").prop("disabled", true);
228 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").prop("disabled", true);
229 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").hide();
230 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").hide();
231 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").hide();
232 jQuery("#MAIN_MAIL_SMTP_SERVER").removeAttr("disabled");
233 jQuery("#MAIN_MAIL_SMTP_PORT").removeAttr("disabled");
234 jQuery("#MAIN_MAIL_SMTP_SERVER").show();
235 jQuery("#MAIN_MAIL_SMTP_PORT").show();
236 jQuery("#smtp_server_mess").hide();
237 jQuery("#smtp_port_mess").hide();
238 jQuery(".smtp_method").show();
239 jQuery(".dkim").hide();
241 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\')
243 console.log("I choose swiftmailer mode");
244 jQuery(".drag").show();
245 jQuery("#MAIN_MAIL_EMAIL_TLS").val('.$conf->global->MAIN_MAIL_EMAIL_TLS.
');
246 jQuery("#MAIN_MAIL_EMAIL_TLS").removeAttr("disabled");
247 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val('.$conf->global->MAIN_MAIL_EMAIL_STARTTLS.
');
248 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").removeAttr("disabled");
249 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val('.$conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED.
');
250 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").removeAttr("disabled");
251 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val('.$conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED.
');
252 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").removeAttr("disabled");
253 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").removeAttr("disabled");
254 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").removeAttr("disabled");
255 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").removeAttr("disabled");
256 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").show();
257 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").show();
258 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").show();
259 jQuery("#MAIN_MAIL_SMTP_SERVER").removeAttr("disabled");
260 jQuery("#MAIN_MAIL_SMTP_PORT").removeAttr("disabled");
261 jQuery("#MAIN_MAIL_SMTP_SERVER").show();
262 jQuery("#MAIN_MAIL_SMTP_PORT").show();
263 jQuery("#smtp_server_mess").hide();
264 jQuery("#smtp_port_mess").hide();
265 jQuery(".smtp_method").show();
266 jQuery(".dkim").show();
270 jQuery("#MAIN_MAIL_SENDMODE").change(function() {
273 jQuery("#MAIN_MAIL_EMAIL_TLS").change(function() {
274 if (jQuery("#MAIN_MAIL_EMAIL_TLS").val() == 1)
275 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(0);
277 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
279 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").change(function() {
280 if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val() == 1)
281 jQuery("#MAIN_MAIL_EMAIL_TLS").val(0);
283 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
286 print
'</script>'.
"\n";
289 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
290 print
'<input type="hidden" name="token" value="'.newToken().
'">';
291 print
'<input type="hidden" name="action" value="update">';
295 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
301 print
'<table class="noborder centpercent">';
302 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
305 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_DISABLE_ALL_MAILS").
'</td><td>';
310 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_FORCE_SENDTO").
'</td><td>';
311 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 :
'').
'" />';
318 print
'<table class="noborder centpercent">';
319 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td></td></tr>';
322 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
325 if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity)) {
326 print
$form->selectarray(
'MAIN_MAIL_SENDMODE', $listofmethods, $conf->global->MAIN_MAIL_SENDMODE);
328 $text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE];
330 $text = $langs->trans(
"Undefined");
332 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
333 print
$form->textwithpicto($text, $htmltext, 1,
'superadmin');
334 print
'<input type="hidden" name="MAIN_MAIL_SENDMODE" value="'.$conf->global->MAIN_MAIL_SENDMODE.
'">';
339 print
'<tr class="oddeven">';
340 if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE ==
'mail') {
342 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
344 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
348 $mainserver = (!empty($conf->global->MAIN_MAIL_SMTP_SERVER) ? $conf->global->MAIN_MAIL_SMTP_SERVER :
'');
349 $smtpserver = ini_get(
'SMTP') ?ini_get(
'SMTP') : $langs->transnoentities(
"Undefined");
351 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
353 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER", $smtpserver);
357 if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
358 print
'<input class="flat minwidth300" id="MAIN_MAIL_SMTP_SERVER" name="MAIN_MAIL_SMTP_SERVER" value="'.$mainserver.
'" autocomplete="off">';
359 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_sav" name="MAIN_MAIL_SMTP_SERVER_sav" value="'.$mainserver.
'">';
360 print
'<span id="smtp_server_mess" class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
361 print
' <span class="opacitymedium smtp_method">'.$langs->trans(
"SeeLinkToOnlineDocumentation").
'</span>';
363 $text = !empty($mainserver) ? $mainserver : $smtpserver;
364 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
365 print
$form->textwithpicto($text, $htmltext, 1,
'superadmin');
366 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER" name="MAIN_MAIL_SMTP_SERVER" value="'.$mainserver.
'">';
373 print
'<tr class="oddeven"><td>';
374 if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE ==
'mail') {
375 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
377 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
379 $mainport = (!empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT :
'');
380 $smtpport = ini_get(
'smtp_port') ?ini_get(
'smtp_port') : $langs->transnoentities(
"Undefined");
382 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
384 print $langs->trans(
"MAIN_MAIL_SMTP_PORT", $smtpport);
388 if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
389 print
'<input class="flat" id="MAIN_MAIL_SMTP_PORT" name="MAIN_MAIL_SMTP_PORT" size="3" value="'.$mainport.
'">';
390 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT_sav" name="MAIN_MAIL_SMTP_PORT_sav" value="'.$mainport.
'">';
391 print
'<span id="smtp_port_mess" class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
393 $text = (!empty($mainport) ? $mainport : $smtpport);
394 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
395 print
$form->textwithpicto($text, $htmltext, 1,
'superadmin');
396 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT" name="MAIN_MAIL_SMTP_PORT" value="'.$mainport.
'">';
402 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array(
'smtps',
'swiftmailer')))) {
403 $mainstmpid = (!empty($conf->global->MAIN_MAIL_SMTPS_ID) ? $conf->global->MAIN_MAIL_SMTPS_ID :
'');
404 print
'<tr class="drag drop oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>';
406 if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
407 print
'<input class="flat" name="MAIN_MAIL_SMTPS_ID" size="32" value="'.$mainstmpid.
'">';
409 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
410 print
$form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_ID, $htmltext, 1,
'superadmin');
411 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_ID" value="'.$mainstmpid.
'">';
417 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array(
'smtps',
'swiftmailer')))) {
418 $mainsmtppw = (!empty($conf->global->MAIN_MAIL_SMTPS_PW) ? $conf->global->MAIN_MAIL_SMTPS_PW :
'');
419 print
'<tr class="drag drop oddeven"><td>';
420 print
$form->textwithpicto($langs->trans(
"MAIN_MAIL_SMTPS_PW"), $langs->trans(
"WithGMailYouCanCreateADedicatedPassword"));
423 if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
424 print
'<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW" size="32" value="'.$mainsmtppw.
'" autocomplete="off">';
426 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
427 print
$form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_PW, $htmltext, 1,
'superadmin');
428 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_PW" value="'.$mainsmtppw.
'">';
434 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
435 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array(
'smtps',
'swiftmailer')))) {
436 if (function_exists(
'openssl_open')) {
437 print
$form->selectyesno(
'MAIN_MAIL_EMAIL_TLS', (!empty($conf->global->MAIN_MAIL_EMAIL_TLS) ? $conf->global->MAIN_MAIL_EMAIL_TLS : 0), 1);
439 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
442 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
447 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
448 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')) {
450 print
$form->selectyesno(
'MAIN_MAIL_EMAIL_STARTTLS', (!empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS) ? $conf->global->MAIN_MAIL_EMAIL_STARTTLS : 0), 1);
452 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
455 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
460 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
461 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array(
'smtps',
'swiftmailer')))) {
462 if (function_exists(
'openssl_open')) {
463 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);
465 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
468 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
473 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_ENABLED").
'</td><td>';
474 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array(
'swiftmailer')))) {
475 if (function_exists(
'openssl_open')) {
476 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);
478 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
481 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
486 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_DOMAIN").
'</td>';
487 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 :
'');
488 print
'"></td></tr>';
491 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_SELECTOR").
'</td>';
492 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 :
'');
493 print
'"></td></tr>';
496 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").
'</td>';
497 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>';
504 print
'<table class="noborder centpercent">';
505 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"OtherOptions").
'</td><td></td></tr>';
508 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>';
509 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 :
'');
510 print
'"></td></tr>';
514 $liste[
'user'] = $langs->trans(
'UserEmail');
515 $liste[
'company'] = $langs->trans(
'CompanyEmail').
' ('.(empty($conf->global->MAIN_INFO_SOCIETE_MAIL) ? $langs->trans(
"NotDefined") : $conf->global->MAIN_INFO_SOCIETE_MAIL).
')';
517 print
'<tr class="oddeven"><td>'.$langs->trans(
'MAIN_MAIL_DEFAULT_FROMTYPE').
'</td><td>';
518 print
$form->selectarray(
'MAIN_MAIL_DEFAULT_FROMTYPE', $liste,
getDolGlobalString(
'MAIN_MAIL_DEFAULT_FROMTYPE'), 0);
522 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ERRORS_TO").
'</td>';
523 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 :
'');
524 print
'"></td></tr>';
527 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_AUTOCOPY_TO").
'</td>';
528 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 :
'');
529 print
'"></td></tr>';
532 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ENABLED_USER_DEST_SELECT").
'</td><td>';
533 print
$form->selectyesno(
'MAIN_MAIL_ENABLED_USER_DEST_SELECT',
getDolGlobalString(
'MAIN_MAIL_ENABLED_USER_DEST_SELECT'), 1);
540 print
$form->buttonsSaveCancel();
546 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
549 print
'<div class="div-table-responsive-no-min">';
550 print
'<table class="noborder centpercent">';
551 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
554 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_DISABLE_ALL_MAILS").
'</td><td>'.
yn(!empty($conf->global->MAIN_DISABLE_ALL_MAILS));
555 if (!empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
560 if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
562 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_FORCE_SENDTO").
'</td><td>'.
getDolGlobalString(
'MAIN_MAIL_FORCE_SENDTO');
567 print
img_warning($langs->trans(
"RecipientEmailsWillBeReplacedWithThisValue"));
576 if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
579 print
'<div class="div-table-responsive-no-min">';
580 print
'<table class="noborder centpercent">';
581 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td></td></tr>';
584 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
585 $text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE];
587 $text = $langs->trans(
"Undefined").img_warning();
591 if ($conf->global->MAIN_MAIL_SENDMODE ==
'mail' && empty($conf->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) {
592 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');
598 if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE ==
'mail')) {
599 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").
'</td><td><span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span></td></tr>';
601 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>';
605 if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE ==
'mail')) {
606 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").
'</td><td><span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span></td></tr>';
608 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>';
612 if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array(
'smtps',
'swiftmailer'))) {
613 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>'.$conf->global->MAIN_MAIL_SMTPS_ID.
'</td></tr>';
617 if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array(
'smtps',
'swiftmailer'))) {
618 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_PW").
'</td><td>'.preg_replace(
'/./',
'*', $conf->global->MAIN_MAIL_SMTPS_PW).
'</td></tr>';
622 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
623 if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array(
'smtps',
'swiftmailer'))) {
624 if (function_exists(
'openssl_open')) {
625 print
yn($conf->global->MAIN_MAIL_EMAIL_TLS);
627 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
630 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
635 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
636 if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array(
'smtps',
'swiftmailer'))) {
637 if (function_exists(
'openssl_open')) {
638 print
yn($conf->global->MAIN_MAIL_EMAIL_STARTTLS);
640 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
643 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
648 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
649 if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array(
'smtps',
'swiftmailer'))) {
650 if (function_exists(
'openssl_open')) {
651 print
yn($conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED);
653 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
656 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
661 if ($conf->global->MAIN_MAIL_SENDMODE ==
'swiftmailer') {
663 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_ENABLED").
'</td><td>';
664 if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array(
'swiftmailer'))) {
665 if (function_exists(
'openssl_open')) {
668 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
671 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
676 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_DOMAIN").
'</td>';
677 print
'<td>'.getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_DOMAIN');
681 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_SELECTOR").
'</td>';
682 print
'<td>'.getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_SELECTOR');
686 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").
'</td>';
687 print
'<td>'.getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY');
694 if ($conf->global->MAIN_MAIL_SENDMODE ==
'mail' && empty($conf->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) {
695 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');
700 print
'<div class="div-table-responsive-no-min">';
701 print
'<table class="noborder centpercent">';
702 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"OtherOptions").
'</td><td></td></tr>';
705 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_FROM", ini_get(
'sendmail_from') ?ini_get(
'sendmail_from') : $langs->transnoentities(
"Undefined")).
'</td>';
706 print
'<td>'.$conf->global->MAIN_MAIL_EMAIL_FROM;
707 if (empty($conf->global->MAIN_MAIL_EMAIL_FROM)) {
709 } elseif (!
isValidEmail($conf->global->MAIN_MAIL_EMAIL_FROM)) {
716 $liste[
'user'] = $langs->trans(
'UserEmail');
717 $liste[
'company'] = $langs->trans(
'CompanyEmail').
' ('.(empty($conf->global->MAIN_INFO_SOCIETE_MAIL) ? $langs->trans(
"NotDefined") : $conf->global->MAIN_INFO_SOCIETE_MAIL).
')';
718 $sql =
'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.
'c_email_senderprofile';
719 $sql .=
' WHERE active = 1 AND (private = 0 OR private = '.((int) $user->id).
')';
720 $resql = $db->query($sql);
722 $num = $db->num_rows(
$resql);
725 $obj = $db->fetch_object(
$resql);
727 $liste[
'senderprofile_'.$obj->rowid] = $obj->label.
' <'.$obj->email.
'>';
735 print
'<tr class="oddeven"><td>'.$langs->trans(
'MAIN_MAIL_DEFAULT_FROMTYPE').
'</td>';
738 print $langs->trans(
'RobotEmail');
740 print $langs->trans(
'UserEmail');
744 $id = preg_replace(
'/senderprofile_/',
'',
getDolGlobalString(
'MAIN_MAIL_DEFAULT_FROMTYPE'));
746 include_once DOL_DOCUMENT_ROOT.
'/core/class/emailsenderprofile.class.php';
748 $emailsenderprofile->fetch($id);
749 print $emailsenderprofile->label.
' '.
dol_escape_htmltag(
'<'.$emailsenderprofile->email.
'>');
755 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ERRORS_TO").
'</td>';
756 print
'<td>'.(getDolGlobalString(
'MAIN_MAIL_ERRORS_TO'));
757 if (!empty($conf->global->MAIN_MAIL_ERRORS_TO) && !
isValidEmail($conf->global->MAIN_MAIL_ERRORS_TO)) {
763 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_AUTOCOPY_TO").
'</td>';
765 if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) {
766 $listofemail = explode(
',', $conf->global->MAIN_MAIL_AUTOCOPY_TO);
768 foreach ($listofemail as $key => $val) {
775 print
img_warning($langs->trans(
"ErrorBadEMail", $val));
785 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ENABLED_USER_DEST_SELECT").
'</td><td>'.
yn(!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)).
'</td></tr>';
795 print
'<div class="tabsAction">';
797 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'">'.$langs->trans(
"Modify").
'</a>';
799 if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
800 if ($conf->global->MAIN_MAIL_SENDMODE !=
'mail' || !$linuxlike) {
801 if (function_exists(
'fsockopen') && $port && $server) {
802 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testconnect&date='.
dol_now().
'#formmailaftertstconnect">'.$langs->trans(
"DoTestServerAvailability").
'</a>';
805 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"FeatureNotAvailableOnLinux").
'">'.$langs->trans(
"DoTestServerAvailability").
'</a>';
808 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=test&mode=init#formmailbeforetitle">'.$langs->trans(
"DoTestSend").
'</a>';
810 if (!empty($conf->fckeditor->enabled)) {
811 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testhtml&mode=init#formmailbeforetitle">'.$langs->trans(
"DoTestSendHTML").
'</a>';
818 if ($conf->global->MAIN_MAIL_SENDMODE ==
'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) {
830 print
info_admin($langs->trans(
"SendmailOptionMayHurtBuggedMTA"));
833 if (!in_array($action, array(
'testconnect',
'test',
'testhtml'))) {
835 if ($conf->global->MAIN_MAIL_SENDMODE ==
'mail') {
839 if ($conf->global->MAIN_MAIL_SENDMODE ==
'mail') {
840 if (!empty($conf->global->MAIN_EXTERNAL_MAIL_SPF_STRING_TO_ADD)) {
842 $text .= ($text ?
'<br><br>' :
'').
'<!-- MAIN_EXTERNAL_MAIL_SPF_STRING_TO_ADD -->'.$langs->trans(
"WarningPHPMailSPF", $conf->global->MAIN_EXTERNAL_MAIL_SPF_STRING_TO_ADD);
845 if (!empty($conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS)) {
847 $text .= ($text ?
'<br><br>' :
'').
'<!-- MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS -->'.$langs->trans(
"WarningPHPMailSPF", $conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS);
851 if (!empty($conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS)) {
854 $text .= ($text ?
'<br><br>' :
'').
'<!-- MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS -->'.$langs->trans(
"WarningPHPMail2", $conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS);
856 if (!empty($conf->global->MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD)) {
858 $text .= ($text ?
'<br><br>' :
'').
'<!-- MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD -->'.$langs->trans(
"WarningPHPMailSPF", $conf->global->MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD);
863 if (!empty($companyemail) && function_exists(
'dns_get_record')) {
864 $arrayofemailparts = explode(
'@', $companyemail);
865 if (count($arrayofemailparts) == 2) {
866 $domain = $arrayofemailparts[1];
867 $dnsinfo = dns_get_record($domain, DNS_TXT);
870 if (!empty($dnsinfo) && is_array($dnsinfo)) {
871 foreach ($dnsinfo as $info) {
872 if (strpos($info[
'txt'],
'v=spf') !==
false) {
873 $text .= ($text ?
'<br><br>' :
'').$langs->trans(
"ActualMailSPFRecordFound", $companyemail, $info[
'txt']);
883 if ($action ==
'testconnect') {
884 print
'<div id="formmailaftertstconnect" name="formmailaftertstconnect"></div>';
887 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
888 $mail =
new CMailFile(
'',
'',
'',
'', array(), array(), array(),
'',
'', 0,
'',
'',
'',
'', $trackid, $sendcontext);
889 $result = $mail->check_server_port($server, $port);
891 print
'<div class="ok">'.$langs->trans(
"ServerAvailableOnIPOrPort", $server, $port).
'</div>';
893 $errormsg = $langs->trans(
"ServerNotAvailableOnIPOrPort", $server, $port);
896 $errormsg .=
' - '.$mail->error;
905 if ($action ==
'test' || $action ==
'testhtml') {
906 print
'<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
907 print
load_fiche_titre($action ==
'testhtml' ? $langs->trans(
"DoTestSendHTML") : $langs->trans(
"DoTestSend"));
912 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
914 $formmail->trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
915 $formmail->fromname = (
GETPOSTISSET(
'fromname') ?
GETPOST(
'fromname') : $conf->global->MAIN_MAIL_EMAIL_FROM);
916 $formmail->frommail = (
GETPOSTISSET(
'frommail') ?
GETPOST(
'frommail') : $conf->global->MAIN_MAIL_EMAIL_FROM);
917 $formmail->fromid = $user->id;
918 $formmail->fromalsorobot = 1;
919 $formmail->fromtype = (
GETPOSTISSET(
'fromtype') ?
GETPOST(
'fromtype',
'aZ09') : (!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE) ? $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE :
'user'));
920 $formmail->withfromreadonly = 1;
921 $formmail->withsubstit = 1;
922 $formmail->withfrom = 1;
923 $formmail->witherrorsto = 1;
924 $formmail->withto = (
GETPOSTISSET(
'sendto') ?
GETPOST(
'sendto',
'restricthtml') : ($user->email ? $user->email : 1));
925 $formmail->withtocc = (
GETPOSTISSET(
'sendtocc') ?
GETPOST(
'sendtocc',
'restricthtml') : 1);
926 $formmail->withtoccc = (
GETPOSTISSET(
'sendtoccc') ?
GETPOST(
'sendtoccc',
'restricthtml') : 1);
927 $formmail->withtopic = (
GETPOSTISSET(
'subject') ?
GETPOST(
'subject') : $langs->trans(
"Test"));
928 $formmail->withtopicreadonly = 0;
929 $formmail->withfile = 2;
930 $formmail->withbody = (
GETPOSTISSET(
'message') ?
GETPOST(
'message',
'restricthtml') : ($action ==
'testhtml' ? $langs->transnoentities(
"PredefinedMailTestHtml") : $langs->transnoentities(
"PredefinedMailTest")));
931 $formmail->withbodyreadonly = 0;
932 $formmail->withcancel = 1;
933 $formmail->withdeliveryreceipt = 1;
934 $formmail->withfckeditor = ($action ==
'testhtml' ? 1 : 0);
935 $formmail->ckeditortoolbar =
'dolibarr_mailings';
937 $formmail->substit = $substitutionarrayfortest;
939 $formmail->param[
"action"] =
"send";
940 $formmail->param[
"models"] =
"body";
941 $formmail->param[
"mailid"] = 0;
942 $formmail->param[
"returnurl"] = $_SERVER[
"PHP_SELF"];
945 if (
GETPOST(
"mode",
"aZ09") ==
'init') {
946 $formmail->clear_attached_files();
949 print $formmail->get_form(
'addfile',
'removefile');
954 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsWillHaveMessageID").
': ';
if($actionsave) if(!isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $wikihelp
View.
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.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
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).
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default= '')
Return dolibarr global constant string value.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
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 from a POST of a form...
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= 'hideonsmartphone', $textfordropdown= '')
Show information for admin users or standard users.
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 ...
if(isModEnabled('facture')&&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur')&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)&&$user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice')&&$user->rights->supplier_invoice->lire)) if(isModEnabled('don')&&!empty($user->rights->don->lire)) if(isModEnabled('tax')&&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture')&&isModEnabled('commande')&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Class for EmailSenderProfile.
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...