27require
'../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
32$langs->loadLangs(array(
'companies',
'products',
'admin',
'mails',
'other',
'errors'));
34$action =
GETPOST(
'action',
'aZ09');
35$cancel =
GETPOST(
'cancel',
'aZ09');
37$usersignature = $user->signature;
39if ($action ==
'test' || $action ==
'send') {
43$substitutionarrayfortest = array(
44 '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT,
45 '__CHECK_READ__' =>
'<img src="'.DOL_MAIN_URL_ROOT.
'/public/emailing/mailing-read.php?tag=undefinedtag&securitykey='.
dol_hash(
getDolGlobalString(
'MAILING_EMAIL_UNSUBSCRIBE_KEY').
"-undefinedtag",
'md5').
'" width="1" height="1" style="width:1px;height:1px" border="0"/>',
46 '__USER_LOGIN__' => $user->login,
47 '__USER_EMAIL__' => $user->email,
48 '__USER_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature :
''),
49 '__SENDEREMAIL_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature :
''),
50 '__ID__' =>
'RecipientIdRecord',
52 '__LOGIN__' => $user->login,
53 '__LASTNAME__' =>
'RecipientLastname',
54 '__FIRSTNAME__' =>
'RecipientFirstname',
55 '__ADDRESS__'=>
'RecipientAddress',
56 '__ZIP__'=>
'RecipientZip',
57 '__TOWN_'=>
'RecipientTown',
58 '__COUNTRY__'=>
'RecipientCountry'
63$listofmethods = array();
64$listofmethods[
'default'] = $langs->trans(
'DefaultOutgoingEmailSetup');
65$listofmethods[
'mail'] =
'PHP mail function';
67$listofmethods[
'smtps'] =
'SMTP/SMTPS socket library';
68if (version_compare(phpversion(),
'7.0',
'>=')) {
69 $listofmethods[
'swiftmailer'] =
'Swift Mailer socket library';
82if ($action ==
'update' && !$cancel) {
84 dolibarr_set_const($db,
"MAIN_MAIL_SENDMODE_EMAILING",
GETPOST(
"MAIN_MAIL_SENDMODE_EMAILING"),
'chaine', 0,
'', $conf->entity);
85 dolibarr_set_const($db,
"MAIN_MAIL_SMTP_PORT_EMAILING",
GETPOST(
"MAIN_MAIL_SMTP_PORT_EMAILING"),
'chaine', 0,
'', $conf->entity);
86 dolibarr_set_const($db,
"MAIN_MAIL_SMTP_SERVER_EMAILING",
GETPOST(
"MAIN_MAIL_SMTP_SERVER_EMAILING"),
'chaine', 0,
'', $conf->entity);
87 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_ID_EMAILING",
GETPOST(
"MAIN_MAIL_SMTPS_ID_EMAILING"),
'chaine', 0,
'', $conf->entity);
88 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_PW_EMAILING")) {
89 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_PW_EMAILING",
GETPOST(
"MAIN_MAIL_SMTPS_PW_EMAILING",
'none'),
'chaine', 0,
'', $conf->entity);
91 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING")) {
92 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING",
GETPOST(
"MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING",
'chaine'),
'chaine', 0,
'', $conf->entity);
94 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING")) {
95 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING",
GETPOST(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING",
'chaine'),
'chaine', 0,
'', $conf->entity);
97 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_TLS_EMAILING",
GETPOST(
"MAIN_MAIL_EMAIL_TLS_EMAILING"),
'chaine', 0,
'', $conf->entity);
98 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_STARTTLS_EMAILING",
GETPOST(
"MAIN_MAIL_EMAIL_STARTTLS_EMAILING"),
'chaine', 0,
'', $conf->entity);
99 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);
101 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?mainmenu=home&leftmenu=setup");
109$triggersendname =
'';
111$mode =
'emailfortest';
112$trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
113$sendcontext =
'emailing';
114include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
116if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'test') {
119if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'testhtml') {
120 $action =
'testhtml';
130$form =
new Form($db);
133if (preg_match(
'/^win/i', PHP_OS)) {
136if (preg_match(
'/^mac/i', PHP_OS)) {
140if (empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING)) {
141 $conf->global->MAIN_MAIL_SENDMODE_EMAILING =
'default';
143$port = !empty($conf->global->MAIN_MAIL_SMTP_PORT_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_PORT_EMAILING : ini_get(
'smtp_port');
147$server = !empty($conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING : ini_get(
'SMTP');
149 $server =
'127.0.0.1';
153$wikihelp =
'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails';
154llxHeader(
'', $langs->trans(
"Setup"), $wikihelp);
161$oauthservices = array();
163foreach ($conf->global as $key => $val) {
164 if (!empty($val) && preg_match(
'/^OAUTH_.*_ID$/', $key)) {
165 $key = preg_replace(
'/^OAUTH_/',
'', $key);
166 $key = preg_replace(
'/_ID$/',
'', $key);
167 if (preg_match(
'/^.*-/', $key)) {
168 $name = preg_replace(
'/^.*-/',
'', $key);
170 $name = $langs->trans(
"NoName");
172 $provider = preg_replace(
'/-.*$/',
'', $key);
173 $provider = ucfirst(strtolower($provider));
175 $oauthservices[$key] = $name.
" (".$provider.
")";
179if ($action ==
'edit') {
180 if ($conf->use_javascript_ajax) {
181 print
"\n".
'<script type="text/javascript">';
182 print
'jQuery(document).ready(function () {
183 function initfields()
185 if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'default\')
187 jQuery(".hideifdefault").hide();
191 jQuery(".hideifdefault").show();
194 if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'mail\')
196 jQuery(".drag").hide();
197 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val(0);
198 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").prop("disabled", true);
199 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val(0);
200 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").prop("disabled", true);
201 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val(0);
202 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").prop("disabled", true);
203 jQuery(".smtp_method").hide();
204 jQuery(".smtp_auth_method").hide();
208 jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").hide();
209 jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").hide();
210 jQuery("#smtp_server_mess").show();
211 jQuery("#smtp_port_mess").show();
215 jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").prop("disabled", true);
216 jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").prop("disabled", true);
217 jQuery("#smtp_server_mess").hide();
218 jQuery("#smtp_port_mess").hide();
223 if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'smtps\')
225 jQuery(".drag").show();
226 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val('.$conf->global->MAIN_MAIL_EMAIL_TLS_EMAILING.
');
227 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").removeAttr("disabled");
228 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val('.$conf->global->MAIN_MAIL_EMAIL_STARTTLS_EMAILING.
');
229 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").removeAttr("disabled");
230 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val('.$conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING.
');
231 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").removeAttr("disabled");
232 jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").removeAttr("disabled");
233 jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").removeAttr("disabled");
234 jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").show();
235 jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").show();
236 jQuery("#smtp_port_mess").hide();
237 jQuery("#smtp_server_mess").hide();
238 jQuery(".smtp_method").show();
239 jQuery(".smtp_auth_method").show();
241 if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'swiftmailer\')
243 jQuery(".drag").show();
244 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val('.$conf->global->MAIN_MAIL_EMAIL_TLS_EMAILING.
');
245 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").removeAttr("disabled");
246 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val('.$conf->global->MAIN_MAIL_EMAIL_STARTTLS_EMAILING.
');
247 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").removeAttr("disabled");
248 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val('.$conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING.
');
249 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").removeAttr("disabled");
250 jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").removeAttr("disabled");
251 jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").removeAttr("disabled");
252 jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").show();
253 jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").show();
254 jQuery("#smtp_server_mess").hide();
255 jQuery("#smtp_port_mess").hide();
256 jQuery(".smtp_method").show();
257 jQuery(".smtp_auth_method").show();
260 function change_smtp_auth_method() {
261 console.log(jQuery("#radio_pw").prop("checked"));
262 if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'smtps\' && jQuery("#radio_oauth").prop("checked")) {
263 jQuery(".smtp_oauth_service").show();
264 jQuery(".smtp_pw").hide();
265 } else if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'swiftmailer\' && jQuery("#radio_oauth").prop("checked")) {
266 jQuery(".smtp_oauth_service").show();
267 jQuery(".smtp_pw").hide();
268 } else if(jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'mail\' || jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'default\'){
269 jQuery(".smtp_oauth_service").hide();
270 jQuery(".smtp_pw").hide();
272 jQuery(".smtp_oauth_service").hide();
273 jQuery(".smtp_pw").show();
277 change_smtp_auth_method();
278 jQuery("#MAIN_MAIL_SENDMODE_EMAILING").change(function() {
280 change_smtp_auth_method();
282 jQuery("#radio_pw, #radio_oauth").change(function() {
283 change_smtp_auth_method();
285 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").change(function() {
286 if (jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val() == 1)
287 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val(0);
289 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val(0);
291 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").change(function() {
292 if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val() == 1)
293 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val(0);
295 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val(0);
298 print
'</script>'.
"\n";
301 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
302 print
'<input type="hidden" name="token" value="'.newToken().
'">';
303 print
'<input type="hidden" name="action" value="update">';
307 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
313 print
'<table class="noborder centpercent">';
314 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
318 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
321 if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity)) {
322 print $form->selectarray(
'MAIN_MAIL_SENDMODE_EMAILING', $listofmethods, $conf->global->MAIN_MAIL_SENDMODE_EMAILING);
324 $text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE_EMAILING];
326 $text = $langs->trans(
"Undefined");
328 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
329 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
330 print
'<input type="hidden" name="MAIN_MAIL_SENDMODE_EMAILING" value="'.$conf->global->MAIN_MAIL_SENDMODE_EMAILING.
'">';
336 print
'<tr class="oddeven hideifdefault">';
337 if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE_EMAILING ==
'mail') {
339 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
341 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
345 $mainserver = (!empty($conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING :
'');
346 $smtpserver = ini_get(
'SMTP') ?ini_get(
'SMTP') : $langs->transnoentities(
"Undefined");
348 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
350 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER", $smtpserver);
354 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
355 print
'<input class="flat minwidth300" id="MAIN_MAIL_SMTP_SERVER_EMAILING" name="MAIN_MAIL_SMTP_SERVER_EMAILING" size="18" value="' . $mainserver .
'">';
356 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_EMAILING_sav" name="MAIN_MAIL_SMTP_SERVER_EMAILING_sav" value="' . $mainserver .
'">';
357 print
'<span id="smtp_server_mess" class="opacitymedium">' . $langs->trans(
"SeeLocalSendMailSetup") .
'</span>';
358 print
' <span class="opacitymedium smtp_method">' . $langs->trans(
"SeeLinkToOnlineDocumentation") .
'</span>';
360 $text = !empty($mainserver) ? $mainserver : $smtpserver;
361 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
362 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
363 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_EMAILING" name="MAIN_MAIL_SMTP_SERVER_EMAILING" value="' . $mainserver .
'">';
371 print
'<tr class="oddeven hideifdefault"><td>';
372 if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE_EMAILING ==
'mail') {
373 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
375 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
377 $mainport = (!empty($conf->global->MAIN_MAIL_SMTP_PORT_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_PORT_EMAILING :
'');
378 $smtpport = ini_get(
'smtp_port') ?ini_get(
'smtp_port') : $langs->transnoentities(
"Undefined");
380 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
382 print $langs->trans(
"MAIN_MAIL_SMTP_PORT", $smtpport);
386 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
387 print
'<input class="flat" id="MAIN_MAIL_SMTP_PORT_EMAILING" name="MAIN_MAIL_SMTP_PORT_EMAILING" size="3" value="' . $mainport .
'">';
388 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT_EMAILING_sav" name="MAIN_MAIL_SMTP_PORT_EMAILING_sav" value="' . $mainport .
'">';
389 print
'<span id="smtp_port_mess" class="opacitymedium">' . $langs->trans(
"SeeLocalSendMailSetup") .
'</span>';
391 $text = (!empty($mainport) ? $mainport : $smtpport);
392 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
393 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
394 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT_EMAILING" name="MAIN_MAIL_SMTP_PORT_EMAILING" value="' . $mainport .
'">';
400 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer')))) {
401 print
'<tr class="oddeven smtp_auth_method hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE").
'</td><td>';
402 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
404 print
'<input type="radio" id="radio_pw" name="MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING" value="LOGIN"'.(getDolGlobalString(
'MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING',
'LOGIN') ==
'LOGIN' ?
' checked' :
'').
'> ';
405 print
'<label for="radio_pw" >'.$langs->trans(
"UsePassword").
'</label>';
406 print
' ';
407 print
'<input type="radio" id="radio_oauth" name="MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING" value="XOAUTH2"'.(getDolGlobalString(
'MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING') ==
'XOAUTH2' ?
' checked' :
'').
'> ';
408 print
'<label for="radio_oauth" >'.$form->textwithpicto($langs->trans(
"UseOauth"), $langs->trans(
"OauthNotAvailableForAllAndHadToBeCreatedBefore")).
'</label>';
411 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
412 print $form->textwithpicto($langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE"), $htmltext, 1,
'superadmin');
413 print
'<input type="hidden" id="MAIN_MAIL_SMTPS_AUTH_TYPE" name="MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING" value="'.$value.
'">';
419 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer')))) {
420 $mainstmpid = (!empty($conf->global->MAIN_MAIL_SMTPS_ID_EMAILING) ? $conf->global->MAIN_MAIL_SMTPS_ID_EMAILING :
'');
421 print
'<tr class="drag drop oddeven hideifdefault"><td>' . $langs->trans(
"MAIN_MAIL_SMTPS_ID") .
'</td><td>';
423 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
424 print
'<input class="flat" name="MAIN_MAIL_SMTPS_ID_EMAILING" size="32" value="' . $mainstmpid .
'">';
426 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
427 print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_ID_EMAILING, $htmltext, 1,
'superadmin');
428 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_ID_EMAILING" value="' . $mainstmpid .
'">';
434 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer')))) {
435 $mainsmtppw = (!empty($conf->global->MAIN_MAIL_SMTPS_PW_EMAILING) ? $conf->global->MAIN_MAIL_SMTPS_PW_EMAILING :
'');
436 print
'<tr class="drag drop oddeven smtp_pw hideifdefault"><td>' . $langs->trans(
"MAIN_MAIL_SMTPS_PW") .
'</td><td>';
438 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
439 print
'<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW_EMAILING" size="32" value="' . $mainsmtppw .
'">';
441 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
442 print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_PW_EMAILING, $htmltext, 1,
'superadmin');
443 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_PW_EMAILING" value="' . $mainsmtppw .
'">';
449 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer')))) {
450 print
'<tr class="oddeven smtp_oauth_service hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE").
'</td><td>';
453 if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity)) {
454 print $form->selectarray(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING', $oauthservices, $conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING);
456 $text = $oauthservices[$conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING];
458 $text = $langs->trans(
"Undefined");
460 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
461 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
462 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING" value="'.$conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING.
'">';
469 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
470 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer')))) {
471 if (function_exists(
'openssl_open')) {
472 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);
474 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
477 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
482 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
483 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer')))) {
484 if (function_exists(
'openssl_open')) {
485 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);
487 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
490 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
495 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
496 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer')))) {
497 if (function_exists(
'openssl_open')) {
498 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);
500 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
503 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
511 print $form->buttonsSaveCancel();
517 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
520 print
'<div class="div-table-responsive-no-min">';
521 print
'<table class="noborder centpercent">';
522 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
525 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
528 $text = $langs->trans(
"Undefined").img_warning();
531 print
'<span class="opacitymedium">'.$text.
'</span>';
537 if (!empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING !=
'default') {
539 if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING ==
'mail')) {
540 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").
'</td><td>'.$langs->trans(
"SeeLocalSendMailSetup").
'</td></tr>';
542 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>';
546 if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING ==
'mail')) {
547 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").
'</td><td>'.$langs->trans(
"SeeLocalSendMailSetup").
'</td></tr>';
549 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>';
553 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE_EMAILING'), array(
'smtps',
'swiftmailer'))) {
555 $text = ($authtype ===
"LOGIN") ? $langs->trans(
"UsePassword") : ($authtype ===
"XOAUTH2" ? $langs->trans(
"UseOauth") :
'') ;
556 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE").
'</td><td>'.$text.
'</td></tr>';
560 if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer'))) {
561 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>'.
getDolGlobalString(
'MAIN_MAIL_SMTPS_ID_EMAILING').
'</td></tr>';
565 if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer')) &&
getDolGlobalString(
'MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING') !=
"XOAUTH2") {
566 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_PW").
'</td><td>'.preg_replace(
'/./',
'*',
getDolGlobalString(
'MAIN_MAIL_SMTPS_PW_EMAILING')).
'</td></tr>';
571 $text = $oauthservices[$conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING];
573 $text = $langs->trans(
"Undefined").img_warning();
575 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING").
'</td><td>'.$text.
'</td></tr>';
580 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
581 if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer'))) {
582 if (function_exists(
'openssl_open')) {
583 print
yn($conf->global->MAIN_MAIL_EMAIL_TLS_EMAILING);
585 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
588 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
593 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
594 if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer'))) {
595 if (function_exists(
'openssl_open')) {
596 print
yn($conf->global->MAIN_MAIL_EMAIL_STARTTLS_EMAILING);
598 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
601 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
606 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
607 if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer'))) {
608 if (function_exists(
'openssl_open')) {
611 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
614 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
625 if ($conf->global->MAIN_MAIL_SENDMODE_EMAILING ==
'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) {
636 print
info_admin($langs->trans(
"SendmailOptionMayHurtBuggedMTA"));
642 print
'<div class="tabsAction">';
644 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.newToken().
'">'.$langs->trans(
"Modify").
'</a>';
646 if (!empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING !=
'default') {
647 if ($conf->global->MAIN_MAIL_SENDMODE_EMAILING !=
'mail' || !$linuxlike) {
648 if (function_exists(
'fsockopen') && $port && $server) {
649 print
'<a class="butAction" href="' . $_SERVER[
"PHP_SELF"] .
'?action=testconnect">' . $langs->trans(
"DoTestServerAvailability") .
'</a>';
652 print
'<a class="butActionRefused classfortooltip" href="#" title="' . $langs->trans(
"FeatureNotAvailableOnLinux") .
'">' . $langs->trans(
"DoTestServerAvailability") .
'</a>';
655 print
'<a class="butAction" href="' . $_SERVER[
"PHP_SELF"] .
'?action=test&mode=init">' . $langs->trans(
"DoTestSend") .
'</a>';
657 if (isModEnabled(
'fckeditor')) {
658 print
'<a class="butAction" href="' . $_SERVER[
"PHP_SELF"] .
'?action=testhtml&mode=init">' . $langs->trans(
"DoTestSendHTML") .
'</a>';
665 if ($conf->global->MAIN_MAIL_SENDMODE_EMAILING ==
'mail' && !in_array($action, array(
'testconnect',
'test',
'testhtml'))) {
666 $text = $langs->trans(
"WarningPHPMail");
671 if ($action ==
'testconnect') {
672 print
'<div id="formmailaftertstconnect" name="formmailaftertstconnect"></div>';
675 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
676 $mail =
new CMailFile(
'',
'',
'',
'', array(), array(), array(),
'',
'', 0,
'',
'',
'',
'', $trackid, $sendcontext);
678 $result = $mail->check_server_port($server, $port);
680 print
'<div class="ok">'.$langs->trans(
"ServerAvailableOnIPOrPort", $server, $port).
'</div>';
682 $errormsg = $langs->trans(
"ServerNotAvailableOnIPOrPort", $server, $port);
685 $errormsg .=
' - '.$mail->error;
694 if ($action ==
'test' || $action ==
'testhtml') {
695 print
'<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
696 print
load_fiche_titre($action ==
'testhtml' ? $langs->trans(
"DoTestSendHTML") : $langs->trans(
"DoTestSend"));
701 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
703 $formmail->trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
704 $formmail->fromname = (GETPOSTISSET(
'fromname') ?
GETPOST(
'fromname',
'restricthtml') : $conf->global->MAIN_MAIL_EMAIL_FROM);
705 $formmail->frommail = (GETPOSTISSET(
'frommail') ?
GETPOST(
'frommail',
'restricthtml') : $conf->global->MAIN_MAIL_EMAIL_FROM);
706 $formmail->fromid = $user->id;
707 $formmail->fromalsorobot = 1;
708 $formmail->withfromreadonly = 0;
709 $formmail->withsubstit = 0;
710 $formmail->withfrom = 1;
711 $formmail->witherrorsto = 1;
712 $formmail->withto = (GETPOSTISSET(
'sendto') ?
GETPOST(
'sendto',
'restricthtml') : ($user->email ? $user->email : 1));
713 $formmail->withtocc = (GETPOSTISSET(
'sendtocc') ?
GETPOST(
'sendtocc',
'restricthtml') : 1);
714 $formmail->withtoccc = (GETPOSTISSET(
'sendtoccc') ?
GETPOST(
'sendtoccc',
'restricthtml') : 1);
715 $formmail->withtopic = (GETPOSTISSET(
'subject') ?
GETPOST(
'subject') : $langs->trans(
"Test"));
716 $formmail->withtopicreadonly = 0;
717 $formmail->withfile = 2;
718 $formmail->withbody = (GETPOSTISSET(
'message') ?
GETPOST(
'message',
'restricthtml') : ($action ==
'testhtml' ? $langs->transnoentities(
"PredefinedMailTestHtml") : $langs->transnoentities(
"PredefinedMailTest")));
719 $formmail->withbodyreadonly = 0;
720 $formmail->withcancel = 1;
721 $formmail->withdeliveryreceipt = 1;
722 $formmail->withfckeditor = ($action ==
'testhtml' ? 1 : 0);
723 $formmail->ckeditortoolbar =
'dolibarr_mailings';
725 $formmail->substit = $substitutionarrayfortest;
727 $formmail->param[
"action"] =
"send";
728 $formmail->param[
"models"] =
"body";
729 $formmail->param[
"mailid"] = 0;
730 $formmail->param[
"returnurl"] = $_SERVER[
"PHP_SELF"];
733 if (
GETPOST(
"mode",
"aZ09") ==
'init') {
734 $formmail->clear_attached_files();
737 print $formmail->get_form(
'addfile',
'removefile');
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).
email_admin_prepare_head()
Return array head with list of tabs to view object informations.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
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...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_hash($chain, $type='0')
Returns a hash (non reversible encryption) of a string.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.