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');
37 $usersignature = $user->signature;
39 if ($action ==
'test' || $action ==
'send')
44 $substitutionarrayfortest = array(
45 '__LOGIN__' => $user->login,
46 '__ID__' =>
'TESTIdRecord',
47 '__EMAIL__' =>
'TESTEMail',
48 '__LASTNAME__' =>
'TESTLastname',
49 '__FIRSTNAME__' =>
'TESTFirstname',
50 '__USER_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature :
''),
61 if ($action ==
'update' && empty($_POST[
"cancel"]))
64 dolibarr_set_const($db,
"MAIN_MAIL_SENDMODE_TICKET",
GETPOST(
"MAIN_MAIL_SENDMODE_TICKET"),
'chaine', 0,
'', $conf->entity);
65 dolibarr_set_const($db,
"MAIN_MAIL_SMTP_PORT_TICKET",
GETPOST(
"MAIN_MAIL_SMTP_PORT_TICKET"),
'chaine', 0,
'', $conf->entity);
66 dolibarr_set_const($db,
"MAIN_MAIL_SMTP_SERVER_TICKET",
GETPOST(
"MAIN_MAIL_SMTP_SERVER_TICKET"),
'chaine', 0,
'', $conf->entity);
67 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_ID_TICKET",
GETPOST(
"MAIN_MAIL_SMTPS_ID_TICKET"),
'chaine', 0,
'', $conf->entity);
68 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_PW_TICKET",
GETPOST(
"MAIN_MAIL_SMTPS_PW_TICKET"),
'chaine', 0,
'', $conf->entity);
69 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_TLS_TICKET",
GETPOST(
"MAIN_MAIL_EMAIL_TLS_TICKET"),
'chaine', 0,
'', $conf->entity);
70 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_STARTTLS_TICKET",
GETPOST(
"MAIN_MAIL_EMAIL_STARTTLS_TICKET"),
'chaine', 0,
'', $conf->entity);
72 header(
"Location: ".
$_SERVER[
"PHP_SELF"].
"?mainmenu=home&leftmenu=setup");
80 $triggersendname =
'';
82 $mode =
'emailfortest';
83 $trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
84 $sendcontext =
'ticket';
85 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
87 if ($action ==
'presend' &&
GETPOST(
'trackid') ==
'test') $action =
'test';
88 if ($action ==
'presend' &&
GETPOST(
'trackid') ==
'testhtml') $action =
'testhtml';
97 $form =
new Form($db);
100 if (preg_match(
'/^win/i', PHP_OS)) $linuxlike = 0;
101 if (preg_match(
'/^mac/i', PHP_OS)) $linuxlike = 0;
103 if (empty($conf->global->MAIN_MAIL_SENDMODE_TICKET)) $conf->global->MAIN_MAIL_SENDMODE_TICKET =
'default';
104 $port = !empty($conf->global->MAIN_MAIL_SMTP_PORT_TICKET) ? $conf->global->MAIN_MAIL_SMTP_PORT_TICKET : ini_get(
'smtp_port');
105 if (!$port) $port = 25;
106 $server = !empty($conf->global->MAIN_MAIL_SMTP_SERVER_TICKET) ? $conf->global->MAIN_MAIL_SMTP_SERVER_TICKET : ini_get(
'SMTP');
107 if (!$server) $server =
'127.0.0.1';
110 $wikihelp =
'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails';
118 $listofmethods = array();
119 $listofmethods[
'default'] = $langs->trans(
'DefaultOutgoingEmailSetup');
120 $listofmethods[
'mail'] =
'PHP mail function';
122 $listofmethods[
'smtps'] =
'SMTP/SMTPS socket library';
123 if (version_compare(phpversion(),
'7.0',
'>=')) $listofmethods[
'swiftmailer'] =
'Swift Mailer socket library';
126 if ($action ==
'edit')
128 if ($conf->use_javascript_ajax)
130 print "\n".
'<script type="text/javascript" language="javascript">';
131 print 'jQuery(document).ready(function () {
132 function initfields()
134 if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'default\')
136 jQuery(".hideifdefault").hide();
140 jQuery(".hideifdefault").show();
143 if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'mail\')
145 jQuery(".drag").hide();
146 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val(0);
147 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").prop("disabled", true);
148 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val(0);
149 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").prop("disabled", true);
154 jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").hide();
155 jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").hide();
156 jQuery("#smtp_server_mess").show();
157 jQuery("#smtp_port_mess").show();
161 jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").prop("disabled", true);
162 jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").prop("disabled", true);
163 jQuery("#smtp_server_mess").hide();
164 jQuery("#smtp_port_mess").hide();
169 if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'smtps\')
171 jQuery(".drag").show();
172 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val('.$conf->global->MAIN_MAIL_EMAIL_TLS_TICKET.
');
173 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").removeAttr("disabled");
174 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val('.$conf->global->MAIN_MAIL_EMAIL_STARTTLS_TICKET.
');
175 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").removeAttr("disabled");
176 jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").removeAttr("disabled");
177 jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").removeAttr("disabled");
178 jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").show();
179 jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").show();
180 jQuery("#smtp_server_mess").hide();
181 jQuery("#smtp_port_mess").hide();
183 if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'swiftmailer\')
185 jQuery(".drag").show();
186 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val('.$conf->global->MAIN_MAIL_EMAIL_TLS_TICKET.
');
187 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").removeAttr("disabled");
188 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val('.$conf->global->MAIN_MAIL_EMAIL_STARTTLS_TICKET.
');
189 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").removeAttr("disabled");
190 jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").removeAttr("disabled");
191 jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").removeAttr("disabled");
192 jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").show();
193 jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").show();
194 jQuery("#smtp_server_mess").hide();
195 jQuery("#smtp_port_mess").hide();
199 jQuery("#MAIN_MAIL_SENDMODE_TICKET").change(function() {
202 jQuery("#MAIN_MAIL_EMAIL_TLS").change(function() {
203 if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val() == 1)
204 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val(0);
206 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").change(function() {
207 if (jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val() == 1)
208 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val(0);
211 print '</script>'.
"\n";
214 print '<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
215 print '<input type="hidden" name="token" value="'.newToken().
'">';
216 print '<input type="hidden" name="action" value="update">';
220 print '<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
226 print '<table class="noborder centpercent">';
227 print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
231 print '<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
234 if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity))
236 print $form->selectarray(
'MAIN_MAIL_SENDMODE_TICKET', $listofmethods, $conf->global->MAIN_MAIL_SENDMODE_TICKET);
238 $text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE_TICKET];
239 if (empty($text)) $text = $langs->trans(
"Undefined");
240 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
241 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
242 print '<input type="hidden" name="MAIN_MAIL_SENDMODE_TICKET" value="'.$conf->global->MAIN_MAIL_SENDMODE_TICKET.
'">';
248 print '<tr class="oddeven hideifdefault"><td>';
249 if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE_TICKET ==
'mail')
251 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
253 print $langs->trans(
"SeeLocalSendMailSetup");
255 $mainserver = (!empty($conf->global->MAIN_MAIL_SMTP_SERVER_TICKET) ? $conf->global->MAIN_MAIL_SMTP_SERVER_TICKET :
'');
256 $smtpserver = ini_get(
'SMTP') ?ini_get(
'SMTP') : $langs->transnoentities(
"Undefined");
257 if ($linuxlike)
print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
258 else print $langs->trans(
"MAIN_MAIL_SMTP_SERVER", $smtpserver);
261 if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity))
263 print '<input class="flat" id="MAIN_MAIL_SMTP_SERVER_TICKET" name="MAIN_MAIL_SMTP_SERVER_TICKET" size="18" value="'.$mainserver.
'">';
264 print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_TICKET_sav" name="MAIN_MAIL_SMTP_SERVER_TICKET_sav" value="'.$mainserver.
'">';
265 print '<span id="smtp_server_mess">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
267 $text = !empty($mainserver) ? $mainserver : $smtpserver;
268 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
269 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
270 print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_TICKET" name="MAIN_MAIL_SMTP_SERVER_TICKET" value="'.$mainserver.
'">';
277 print '<tr class="oddeven hideifdefault"><td>';
278 if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE_TICKET ==
'mail')
280 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
282 print $langs->trans(
"SeeLocalSendMailSetup");
284 $mainport = (!empty($conf->global->MAIN_MAIL_SMTP_PORT_TICKET) ? $conf->global->MAIN_MAIL_SMTP_PORT_TICKET :
'');
285 $smtpport = ini_get(
'smtp_port') ?ini_get(
'smtp_port') : $langs->transnoentities(
"Undefined");
286 if ($linuxlike)
print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
287 else print $langs->trans(
"MAIN_MAIL_SMTP_PORT", $smtpport);
290 if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity))
292 print '<input class="flat" id="MAIN_MAIL_SMTP_PORT_TICKET" name="MAIN_MAIL_SMTP_PORT_TICKET" size="3" value="'.$mainport.
'">';
293 print '<input type="hidden" id="MAIN_MAIL_SMTP_PORT_TICKET_sav" name="MAIN_MAIL_SMTP_PORT_TICKET_sav" value="'.$mainport.
'">';
294 print '<span id="smtp_port_mess">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
296 $text = (!empty($mainport) ? $mainport : $smtpport);
297 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
298 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
299 print '<input type="hidden" id="MAIN_MAIL_SMTP_PORT_TICKET" name="MAIN_MAIL_SMTP_PORT_TICKET" value="'.$mainport.
'">';
305 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer'))))
307 $mainstmpid = (!empty($conf->global->MAIN_MAIL_SMTPS_ID_TICKET) ? $conf->global->MAIN_MAIL_SMTPS_ID_TICKET :
'');
308 print '<tr class="drag drop oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>';
310 if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity))
312 print '<input class="flat" name="MAIN_MAIL_SMTPS_ID_TICKET" size="32" value="'.$mainstmpid.
'">';
314 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
315 print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_ID_TICKET, $htmltext, 1,
'superadmin');
316 print '<input type="hidden" name="MAIN_MAIL_SMTPS_ID_TICKET" value="'.$mainstmpid.
'">';
322 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer'))))
324 $mainsmtppw = (!empty($conf->global->MAIN_MAIL_SMTPS_PW_TICKET) ? $conf->global->MAIN_MAIL_SMTPS_PW_TICKET :
'');
325 print '<tr class="drag drop oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_PW").
'</td><td>';
327 if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity))
329 print '<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW_TICKET" size="32" value="'.$mainsmtppw.
'">';
331 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
332 print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_PW_TICKET, $htmltext, 1,
'superadmin');
333 print '<input type="hidden" name="MAIN_MAIL_SMTPS_PW_TICKET" value="'.$mainsmtppw.
'">';
340 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
341 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer'))))
343 if (function_exists(
'openssl_open'))
345 print $form->selectyesno(
'MAIN_MAIL_EMAIL_TLS_TICKET', (!empty($conf->global->MAIN_MAIL_EMAIL_TLS_TICKET) ? $conf->global->MAIN_MAIL_EMAIL_TLS_TICKET : 0), 1);
346 }
else print yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
347 }
else print yn(0).
' ('.$langs->trans(
"NotSupported").
')';
352 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
353 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer'))))
355 if (function_exists(
'openssl_open'))
357 print $form->selectyesno(
'MAIN_MAIL_EMAIL_STARTTLS_TICKET', (!empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS_TICKET) ? $conf->global->MAIN_MAIL_EMAIL_STARTTLS_TICKET : 0), 1);
358 }
else print yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
359 }
else print yn(0).
' ('.$langs->trans(
"NotSupported").
')';
366 print '<br><div class="center">';
367 print '<input class="button button-save" type="submit" name="save" value="'.$langs->trans(
"Save").
'">';
368 print ' ';
369 print '<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
376 print '<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
379 print '<table class="noborder centpercent">';
380 print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
383 print '<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
384 $text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE_TICKET];
385 if (empty($text)) $text = $langs->trans(
"Undefined").img_warning();
389 if (!empty($conf->global->MAIN_MAIL_SENDMODE_TICKET) && $conf->global->MAIN_MAIL_SENDMODE_TICKET !=
'default')
392 if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && $conf->global->MAIN_MAIL_SENDMODE_TICKET ==
'mail'))
394 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").
'</td><td>'.$langs->trans(
"SeeLocalSendMailSetup").
'</td></tr>';
396 print '<tr class="oddeven hideifdefault"><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_TICKET) ? $conf->global->MAIN_MAIL_SMTP_SERVER_TICKET :
'').
'</td></tr>';
400 if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && $conf->global->MAIN_MAIL_SENDMODE_TICKET ==
'mail'))
402 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").
'</td><td>'.$langs->trans(
"SeeLocalSendMailSetup").
'</td></tr>';
404 print '<tr class="oddeven hideifdefault"><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_TICKET) ? $conf->global->MAIN_MAIL_SMTP_PORT_TICKET :
'').
'</td></tr>';
408 if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer')))
410 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>'.$conf->global->MAIN_MAIL_SMTPS_ID_TICKET.
'</td></tr>';
414 if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer')))
416 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_PW").
'</td><td>'.preg_replace(
'/./',
'*', $conf->global->MAIN_MAIL_SMTPS_PW_TICKET).
'</td></tr>';
420 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
421 if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer')))
423 if (function_exists(
'openssl_open'))
425 print yn($conf->global->MAIN_MAIL_EMAIL_TLS_TICKET);
426 }
else print yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
427 }
else print yn(0).
' ('.$langs->trans(
"NotSupported").
')';
431 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
432 if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer')))
434 if (function_exists(
'openssl_open'))
436 print yn($conf->global->MAIN_MAIL_EMAIL_STARTTLS_TICKET);
437 }
else print yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
438 }
else print yn(0).
' ('.$langs->trans(
"NotSupported").
')';
447 if ($conf->global->MAIN_MAIL_SENDMODE_TICKET ==
'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA))
467 print '<div class="tabsAction">';
469 print '<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit">'.$langs->trans(
"Modify").
'</a>';
471 if (!empty($conf->global->MAIN_MAIL_SENDMODE_TICKET) && $conf->global->MAIN_MAIL_SENDMODE_TICKET !=
'default')
473 if ($conf->global->MAIN_MAIL_SENDMODE_TICKET !=
'mail' || !$linuxlike)
475 if (function_exists(
'fsockopen') && $port && $server)
477 print '<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testconnect">'.$langs->trans(
"DoTestServerAvailability").
'</a>';
480 print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"FeatureNotAvailableOnLinux").
'">'.$langs->trans(
"DoTestServerAvailability").
'</a>';
483 print '<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=test&mode=init">'.$langs->trans(
"DoTestSend").
'</a>';
485 if (!empty($conf->fckeditor->enabled))
487 print '<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testhtml&mode=init">'.$langs->trans(
"DoTestSendHTML").
'</a>';
494 if ($conf->global->MAIN_MAIL_SENDMODE_TICKET ==
'mail' && !in_array($action, array(
'testconnect',
'test',
'testhtml')))
496 $text = $langs->trans(
"WarningPHPMail");
501 if ($action ==
'testconnect')
505 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
506 $mail =
new CMailFile(
'',
'',
'',
'', array(), array(), array(),
'',
'', 0,
'',
'',
'',
'', $trackid, $sendcontext);
508 $result = $mail->check_server_port($server, $port);
509 if ($result)
print '<div class="ok">'.$langs->trans(
"ServerAvailableOnIPOrPort", $server, $port).
'</div>';
511 $errormsg = $langs->trans(
"ServerNotAvailableOnIPOrPort", $server, $port);
514 $errormsg .=
' - '.$mail->error;
523 if ($action ==
'test' || $action ==
'testhtml')
525 print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
526 print load_fiche_titre($action ==
'testhtml' ? $langs->trans(
"DoTestSendHTML") : $langs->trans(
"DoTestSend"));
531 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
533 $formmail->fromname = (
GETPOSTISSET(
'fromname') ? $_POST[
'fromname'] : $conf->global->MAIN_MAIL_EMAIL_FROM);
534 $formmail->frommail = (
GETPOSTISSET(
'frommail') ? $_POST[
'frommail'] : $conf->global->MAIN_MAIL_EMAIL_FROM);
535 $formmail->trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
536 $formmail->withfromreadonly = 0;
537 $formmail->withsubstit = 0;
538 $formmail->withfrom = 1;
539 $formmail->witherrorsto = 1;
540 $formmail->withto = (!empty($_POST[
'sendto']) ?
GETPOST(
'sendto',
'restricthtml') : ($user->email ? $user->email : 1));
541 $formmail->withtocc = (!empty($_POST[
'sendtocc']) ?
GETPOST(
'sendtocc',
'restricthtml') : 1);
542 $formmail->withtoccc = (!empty($_POST[
'sendtoccc']) ?
GETPOST(
'sendtoccc',
'restricthtml') : 1);
543 $formmail->withtopic = (
GETPOSTISSET(
'subject') ?
GETPOST(
'subject') : $langs->trans(
"Test"));
544 $formmail->withtopicreadonly = 0;
545 $formmail->withfile = 2;
546 $formmail->withbody = (
GETPOSTISSET(
'message') ?
GETPOST(
'message',
'restricthtml') : ($action ==
'testhtml' ? $langs->transnoentities(
"PredefinedMailTestHtml") : $langs->transnoentities(
"PredefinedMailTest")));
547 $formmail->withbodyreadonly = 0;
548 $formmail->withcancel = 1;
549 $formmail->withdeliveryreceipt = 1;
550 $formmail->withfckeditor = ($action ==
'testhtml' ? 1 : 0);
551 $formmail->ckeditortoolbar =
'dolibarr_mailings';
553 $formmail->substit = $substitutionarrayfortest;
555 $formmail->param[
"action"] =
"send";
556 $formmail->param[
"models"] =
"body";
557 $formmail->param[
"mailid"] = 0;
558 $formmail->param[
"returnurl"] =
$_SERVER[
"PHP_SELF"];
563 $formmail->clear_attached_files();
566 print $formmail->get_form(
'addfile',
'removefile');
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.
email_admin_prepare_head()
Return array head with list of tabs to view object informations.
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(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.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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...