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_EMAILING",
GETPOST(
"MAIN_MAIL_SENDMODE_EMAILING"),
'chaine', 0,
'', $conf->entity);
65 dolibarr_set_const($db,
"MAIN_MAIL_SMTP_PORT_EMAILING",
GETPOST(
"MAIN_MAIL_SMTP_PORT_EMAILING"),
'chaine', 0,
'', $conf->entity);
66 dolibarr_set_const($db,
"MAIN_MAIL_SMTP_SERVER_EMAILING",
GETPOST(
"MAIN_MAIL_SMTP_SERVER_EMAILING"),
'chaine', 0,
'', $conf->entity);
67 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_ID_EMAILING",
GETPOST(
"MAIN_MAIL_SMTPS_ID_EMAILING"),
'chaine', 0,
'', $conf->entity);
68 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_PW_EMAILING",
GETPOST(
"MAIN_MAIL_SMTPS_PW_EMAILING"),
'chaine', 0,
'', $conf->entity);
69 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_TLS_EMAILING",
GETPOST(
"MAIN_MAIL_EMAIL_TLS_EMAILING"),
'chaine', 0,
'', $conf->entity);
70 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_STARTTLS_EMAILING",
GETPOST(
"MAIN_MAIL_EMAIL_STARTTLS_EMAILING"),
'chaine', 0,
'', $conf->entity);
71 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING",
GETPOST(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING"),
'chaine', 0,
'', $conf->entity);
73 header(
"Location: ".
$_SERVER[
"PHP_SELF"].
"?mainmenu=home&leftmenu=setup");
81 $triggersendname =
'';
83 $mode =
'emailfortest';
84 $trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
85 $sendcontext =
'emailing';
86 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
88 if ($action ==
'presend' &&
GETPOST(
'trackid') ==
'test') $action =
'test';
89 if ($action ==
'presend' &&
GETPOST(
'trackid') ==
'testhtml') $action =
'testhtml';
98 $form =
new Form($db);
101 if (preg_match(
'/^win/i', PHP_OS)) $linuxlike = 0;
102 if (preg_match(
'/^mac/i', PHP_OS)) $linuxlike = 0;
104 if (empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING)) $conf->global->MAIN_MAIL_SENDMODE_EMAILING =
'default';
105 $port = !empty($conf->global->MAIN_MAIL_SMTP_PORT_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_PORT_EMAILING : ini_get(
'smtp_port');
106 if (!$port) $port = 25;
107 $server = !empty($conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING : ini_get(
'SMTP');
108 if (!$server) $server =
'127.0.0.1';
111 $wikihelp =
'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails';
119 $listofmethods = array();
120 $listofmethods[
'default'] = $langs->trans(
'DefaultOutgoingEmailSetup');
121 $listofmethods[
'mail'] =
'PHP mail function';
123 $listofmethods[
'smtps'] =
'SMTP/SMTPS socket library';
124 if (version_compare(phpversion(),
'7.0',
'>=')) $listofmethods[
'swiftmailer'] =
'Swift Mailer socket library';
127 if ($action ==
'edit')
129 if ($conf->use_javascript_ajax)
131 print "\n".
'<script type="text/javascript" language="javascript">';
132 print 'jQuery(document).ready(function () {
133 function initfields()
135 if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'default\')
137 jQuery(".hideifdefault").hide();
141 jQuery(".hideifdefault").show();
144 if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'mail\')
146 jQuery(".drag").hide();
147 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val(0);
148 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").prop("disabled", true);
149 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val(0);
150 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").prop("disabled", true);
151 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val(0);
152 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").prop("disabled", true);
157 jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").hide();
158 jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").hide();
159 jQuery("#smtp_server_mess").show();
160 jQuery("#smtp_port_mess").show();
164 jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").prop("disabled", true);
165 jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").prop("disabled", true);
166 jQuery("#smtp_server_mess").hide();
167 jQuery("#smtp_port_mess").hide();
172 if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'smtps\')
174 jQuery(".drag").show();
175 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val('.$conf->global->MAIN_MAIL_EMAIL_TLS_EMAILING.
');
176 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").removeAttr("disabled");
177 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val('.$conf->global->MAIN_MAIL_EMAIL_STARTTLS_EMAILING.
');
178 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").removeAttr("disabled");
179 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val('.$conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING.
');
180 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").removeAttr("disabled");
181 jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").removeAttr("disabled");
182 jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").removeAttr("disabled");
183 jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").show();
184 jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").show();
185 jQuery("#smtp_server_mess").hide();
186 jQuery("#smtp_port_mess").hide();
188 if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'swiftmailer\')
190 jQuery(".drag").show();
191 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val('.$conf->global->MAIN_MAIL_EMAIL_TLS_EMAILING.
');
192 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").removeAttr("disabled");
193 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val('.$conf->global->MAIN_MAIL_EMAIL_STARTTLS_EMAILING.
');
194 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").removeAttr("disabled");
195 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val('.$conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING.
');
196 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").removeAttr("disabled");
197 jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").removeAttr("disabled");
198 jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").removeAttr("disabled");
199 jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").show();
200 jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").show();
201 jQuery("#smtp_server_mess").hide();
202 jQuery("#smtp_port_mess").hide();
206 jQuery("#MAIN_MAIL_SENDMODE_EMAILING").change(function() {
209 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").change(function() {
210 if (jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val() == 1)
211 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val(0);
213 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val(0);
215 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").change(function() {
216 if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val() == 1)
217 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val(0);
219 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val(0);
222 print '</script>'.
"\n";
225 print '<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
226 print '<input type="hidden" name="token" value="'.newToken().
'">';
227 print '<input type="hidden" name="action" value="update">';
231 print '<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
237 print '<table class="noborder centpercent">';
238 print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
242 print '<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
245 if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity))
247 print $form->selectarray(
'MAIN_MAIL_SENDMODE_EMAILING', $listofmethods, $conf->global->MAIN_MAIL_SENDMODE_EMAILING);
249 $text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE_EMAILING];
250 if (empty($text)) $text = $langs->trans(
"Undefined");
251 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
252 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
253 print '<input type="hidden" name="MAIN_MAIL_SENDMODE_EMAILING" value="'.$conf->global->MAIN_MAIL_SENDMODE_EMAILING.
'">';
259 print '<tr class="oddeven hideifdefault"><td>';
260 if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE_EMAILING ==
'mail')
262 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
264 print $langs->trans(
"SeeLocalSendMailSetup");
266 $mainserver = (!empty($conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING :
'');
267 $smtpserver = ini_get(
'SMTP') ?ini_get(
'SMTP') : $langs->transnoentities(
"Undefined");
268 if ($linuxlike)
print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
269 else print $langs->trans(
"MAIN_MAIL_SMTP_SERVER", $smtpserver);
272 if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity))
274 print '<input class="flat" id="MAIN_MAIL_SMTP_SERVER_EMAILING" name="MAIN_MAIL_SMTP_SERVER_EMAILING" size="18" value="'.$mainserver.
'">';
275 print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_EMAILING_sav" name="MAIN_MAIL_SMTP_SERVER_EMAILING_sav" value="'.$mainserver.
'">';
276 print '<span id="smtp_server_mess">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
278 $text = !empty($mainserver) ? $mainserver : $smtpserver;
279 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
280 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
281 print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_EMAILING" name="MAIN_MAIL_SMTP_SERVER_EMAILING" value="'.$mainserver.
'">';
288 print '<tr class="oddeven hideifdefault"><td>';
289 if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE_EMAILING ==
'mail')
291 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
293 print $langs->trans(
"SeeLocalSendMailSetup");
295 $mainport = (!empty($conf->global->MAIN_MAIL_SMTP_PORT_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_PORT_EMAILING :
'');
296 $smtpport = ini_get(
'smtp_port') ?ini_get(
'smtp_port') : $langs->transnoentities(
"Undefined");
297 if ($linuxlike)
print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
298 else print $langs->trans(
"MAIN_MAIL_SMTP_PORT", $smtpport);
301 if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity))
303 print '<input class="flat" id="MAIN_MAIL_SMTP_PORT_EMAILING" name="MAIN_MAIL_SMTP_PORT_EMAILING" size="3" value="'.$mainport.
'">';
304 print '<input type="hidden" id="MAIN_MAIL_SMTP_PORT_EMAILING_sav" name="MAIN_MAIL_SMTP_PORT_EMAILING_sav" value="'.$mainport.
'">';
305 print '<span id="smtp_port_mess">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
307 $text = (!empty($mainport) ? $mainport : $smtpport);
308 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
309 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
310 print '<input type="hidden" id="MAIN_MAIL_SMTP_PORT_EMAILING" name="MAIN_MAIL_SMTP_PORT_EMAILING" value="'.$mainport.
'">';
316 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer'))))
318 $mainstmpid = (!empty($conf->global->MAIN_MAIL_SMTPS_ID_EMAILING) ? $conf->global->MAIN_MAIL_SMTPS_ID_EMAILING :
'');
319 print '<tr class="drag drop oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>';
321 if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity))
323 print '<input class="flat" name="MAIN_MAIL_SMTPS_ID_EMAILING" size="32" value="'.$mainstmpid.
'">';
325 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
326 print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_ID_EMAILING, $htmltext, 1,
'superadmin');
327 print '<input type="hidden" name="MAIN_MAIL_SMTPS_ID_EMAILING" value="'.$mainstmpid.
'">';
333 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer'))))
335 $mainsmtppw = (!empty($conf->global->MAIN_MAIL_SMTPS_PW_EMAILING) ? $conf->global->MAIN_MAIL_SMTPS_PW_EMAILING :
'');
336 print '<tr class="drag drop oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_PW").
'</td><td>';
338 if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity))
340 print '<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW_EMAILING" size="32" value="'.$mainsmtppw.
'">';
342 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
343 print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_PW_EMAILING, $htmltext, 1,
'superadmin');
344 print '<input type="hidden" name="MAIN_MAIL_SMTPS_PW_EMAILING" value="'.$mainsmtppw.
'">';
351 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
352 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer'))))
354 if (function_exists(
'openssl_open'))
356 print $form->selectyesno(
'MAIN_MAIL_EMAIL_TLS_EMAILING', (!empty($conf->global->MAIN_MAIL_EMAIL_TLS_EMAILING) ? $conf->global->MAIN_MAIL_EMAIL_TLS_EMAILING : 0), 1);
357 }
else print yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
358 }
else print yn(0).
' ('.$langs->trans(
"NotSupported").
')';
363 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
364 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer'))))
366 if (function_exists(
'openssl_open'))
368 print $form->selectyesno(
'MAIN_MAIL_EMAIL_STARTTLS_EMAILING', (!empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS_EMAILING) ? $conf->global->MAIN_MAIL_EMAIL_STARTTLS_EMAILING : 0), 1);
369 }
else print yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
370 }
else print yn(0).
' ('.$langs->trans(
"NotSupported").
')';
375 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
376 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer'))))
378 if (function_exists(
'openssl_open'))
380 print $form->selectyesno(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING', (!empty($conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING) ? $conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING : 0), 1);
381 }
else print yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
382 }
else print yn(0).
' ('.$langs->trans(
"NotSupported").
')';
389 print '<br><div class="center">';
390 print '<input class="button button-save" type="submit" name="save" value="'.$langs->trans(
"Save").
'">';
391 print ' ';
392 print '<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
399 print '<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
402 print '<table class="noborder centpercent">';
403 print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
406 print '<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
407 $text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE_EMAILING];
408 if (empty($text)) $text = $langs->trans(
"Undefined").img_warning();
412 if (!empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING !=
'default')
415 if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING ==
'mail'))
417 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").
'</td><td>'.$langs->trans(
"SeeLocalSendMailSetup").
'</td></tr>';
419 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_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING :
'').
'</td></tr>';
423 if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING ==
'mail'))
425 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").
'</td><td>'.$langs->trans(
"SeeLocalSendMailSetup").
'</td></tr>';
427 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_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_PORT_EMAILING :
'').
'</td></tr>';
431 if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer')))
433 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>'.$conf->global->MAIN_MAIL_SMTPS_ID_EMAILING.
'</td></tr>';
437 if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer')))
439 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_PW").
'</td><td>'.preg_replace(
'/./',
'*', $conf->global->MAIN_MAIL_SMTPS_PW_EMAILING).
'</td></tr>';
443 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
444 if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer')))
446 if (function_exists(
'openssl_open'))
448 print yn($conf->global->MAIN_MAIL_EMAIL_TLS_EMAILING);
449 }
else print yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
450 }
else print yn(0).
' ('.$langs->trans(
"NotSupported").
')';
454 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
455 if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer')))
457 if (function_exists(
'openssl_open'))
459 print yn($conf->global->MAIN_MAIL_EMAIL_STARTTLS_EMAILING);
460 }
else print yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
461 }
else print yn(0).
' ('.$langs->trans(
"NotSupported").
')';
465 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
466 if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer')))
468 if (function_exists(
'openssl_open'))
470 print yn($conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING);
471 }
else print yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
472 }
else print yn(0).
' ('.$langs->trans(
"NotSupported").
')';
481 if ($conf->global->MAIN_MAIL_SENDMODE_EMAILING ==
'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA))
501 print '<div class="tabsAction">';
503 print '<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit">'.$langs->trans(
"Modify").
'</a>';
505 if (!empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING !=
'default')
507 if ($conf->global->MAIN_MAIL_SENDMODE_EMAILING !=
'mail' || !$linuxlike)
509 if (function_exists(
'fsockopen') && $port && $server)
511 print '<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testconnect">'.$langs->trans(
"DoTestServerAvailability").
'</a>';
514 print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"FeatureNotAvailableOnLinux").
'">'.$langs->trans(
"DoTestServerAvailability").
'</a>';
517 print '<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=test&mode=init">'.$langs->trans(
"DoTestSend").
'</a>';
519 if (!empty($conf->fckeditor->enabled))
521 print '<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testhtml&mode=init">'.$langs->trans(
"DoTestSendHTML").
'</a>';
528 if ($conf->global->MAIN_MAIL_SENDMODE_EMAILING ==
'mail' && !in_array($action, array(
'testconnect',
'test',
'testhtml')))
530 $text = $langs->trans(
"WarningPHPMail");
535 if ($action ==
'testconnect')
539 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
540 $mail =
new CMailFile(
'',
'',
'',
'', array(), array(), array(),
'',
'', 0,
'',
'',
'',
'', $trackid, $sendcontext);
542 $result = $mail->check_server_port($server, $port);
543 if ($result)
print '<div class="ok">'.$langs->trans(
"ServerAvailableOnIPOrPort", $server, $port).
'</div>';
545 $errormsg = $langs->trans(
"ServerNotAvailableOnIPOrPort", $server, $port);
548 $errormsg .=
' - '.$mail->error;
557 if ($action ==
'test' || $action ==
'testhtml')
559 print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
560 print load_fiche_titre($action ==
'testhtml' ? $langs->trans(
"DoTestSendHTML") : $langs->trans(
"DoTestSend"));
565 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
567 $formmail->fromname = (
GETPOSTISSET(
'fromname') ?
GETPOST(
'fromname',
'restricthtml') : $conf->global->MAIN_MAIL_EMAIL_FROM);
568 $formmail->frommail = (
GETPOSTISSET(
'frommail') ?
GETPOST(
'frommail',
'restricthtml') : $conf->global->MAIN_MAIL_EMAIL_FROM);
569 $formmail->trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
570 $formmail->withfromreadonly = 0;
571 $formmail->withsubstit = 0;
572 $formmail->withfrom = 1;
573 $formmail->witherrorsto = 1;
574 $formmail->withto = (!
GETPOST(
'sendto') ?
GETPOST(
'sendto',
'restricthtml') : ($user->email ? $user->email : 1));
575 $formmail->withtocc = (!
GETPOST([
'sendtocc']) ?
GETPOST(
'sendtocc',
'restricthtml') : 1);
576 $formmail->withtoccc = (!
GETPOST([
'sendtoccc']) ?
GETPOST(
'sendtoccc',
'restricthtml') : 1);
577 $formmail->withtopic = (
GETPOSTISSET(
'subject') ?
GETPOST(
'subject') : $langs->trans(
"Test"));
578 $formmail->withtopicreadonly = 0;
579 $formmail->withfile = 2;
580 $formmail->withbody = (
GETPOSTISSET(
'message') ?
GETPOST(
'message',
'restricthtml') : ($action ==
'testhtml' ? $langs->transnoentities(
"PredefinedMailTestHtml") : $langs->transnoentities(
"PredefinedMailTest")));
581 $formmail->withbodyreadonly = 0;
582 $formmail->withcancel = 1;
583 $formmail->withdeliveryreceipt = 1;
584 $formmail->withfckeditor = ($action ==
'testhtml' ? 1 : 0);
585 $formmail->ckeditortoolbar =
'dolibarr_mailings';
587 $formmail->substit = $substitutionarrayfortest;
589 $formmail->param[
"action"] =
"send";
590 $formmail->param[
"models"] =
"body";
591 $formmail->param[
"mailid"] = 0;
592 $formmail->param[
"returnurl"] =
$_SERVER[
"PHP_SELF"];
597 $formmail->clear_attached_files();
600 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...