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 && !
getDolGlobalString(
'MAIN_MAIL_DO_NOT_USE_SIGN')) ? $usersignature :
''),
49 '__SENDEREMAIL_SIGNATURE__' => (($user->signature && !
getDolGlobalString(
'MAIN_MAIL_DO_NOT_USE_SIGN')) ? $usersignature :
''),
50 '__ID__' =>
'RecipientIdRecord',
52 '__LASTNAME__' =>
'RecipientLastname',
53 '__FIRSTNAME__' =>
'RecipientFirstname',
54 '__ADDRESS__'=>
'RecipientAddress',
55 '__ZIP__'=>
'RecipientZip',
56 '__TOWN_'=>
'RecipientTown',
57 '__COUNTRY__'=>
'RecipientCountry'
62$listofmethods = array();
63$listofmethods[
'default'] = $langs->trans(
'DefaultOutgoingEmailSetup');
64$listofmethods[
'mail'] =
'PHP mail function';
66$listofmethods[
'smtps'] =
'SMTP/SMTPS socket library';
67if (version_compare(phpversion(),
'7.0',
'>=')) {
68 $listofmethods[
'swiftmailer'] =
'Swift Mailer socket library';
81if ($action ==
'update' && !$cancel) {
83 dolibarr_set_const($db,
"MAIN_MAIL_SENDMODE_EMAILING",
GETPOST(
"MAIN_MAIL_SENDMODE_EMAILING"),
'chaine', 0,
'', $conf->entity);
84 dolibarr_set_const($db,
"MAIN_MAIL_SMTP_PORT_EMAILING",
GETPOST(
"MAIN_MAIL_SMTP_PORT_EMAILING"),
'chaine', 0,
'', $conf->entity);
85 dolibarr_set_const($db,
"MAIN_MAIL_SMTP_SERVER_EMAILING",
GETPOST(
"MAIN_MAIL_SMTP_SERVER_EMAILING"),
'chaine', 0,
'', $conf->entity);
86 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_ID_EMAILING",
GETPOST(
"MAIN_MAIL_SMTPS_ID_EMAILING"),
'chaine', 0,
'', $conf->entity);
87 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_PW_EMAILING")) {
88 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_PW_EMAILING",
GETPOST(
"MAIN_MAIL_SMTPS_PW_EMAILING",
'none'),
'chaine', 0,
'', $conf->entity);
90 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING")) {
91 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING",
GETPOST(
"MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING",
'chaine'),
'chaine', 0,
'', $conf->entity);
93 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING")) {
94 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING",
GETPOST(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING",
'chaine'),
'chaine', 0,
'', $conf->entity);
96 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_TLS_EMAILING",
GETPOST(
"MAIN_MAIL_EMAIL_TLS_EMAILING"),
'chaine', 0,
'', $conf->entity);
97 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_STARTTLS_EMAILING",
GETPOST(
"MAIN_MAIL_EMAIL_STARTTLS_EMAILING"),
'chaine', 0,
'', $conf->entity);
98 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);
100 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?mainmenu=home&leftmenu=setup");
108$triggersendname =
'';
110$mode =
'emailfortest';
111$trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
112$sendcontext =
'emailing';
113include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
115if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'test') {
118if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'testhtml') {
119 $action =
'testhtml';
129$form =
new Form($db);
132if (preg_match(
'/^win/i', PHP_OS)) {
135if (preg_match(
'/^mac/i', PHP_OS)) {
140 $conf->global->MAIN_MAIL_SENDMODE_EMAILING =
'default';
142$port =
getDolGlobalString(
'MAIN_MAIL_SMTP_PORT_EMAILING') ? $conf->global->MAIN_MAIL_SMTP_PORT_EMAILING : ini_get(
'smtp_port');
146$server =
getDolGlobalString(
'MAIN_MAIL_SMTP_SERVER_EMAILING') ? $conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING : ini_get(
'SMTP');
148 $server =
'127.0.0.1';
152$wikihelp =
'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails';
153llxHeader(
'', $langs->trans(
"Setup"), $wikihelp);
160$oauthservices = array();
162foreach ($conf->global as $key => $val) {
163 if (!empty($val) && preg_match(
'/^OAUTH_.*_ID$/', $key)) {
164 $key = preg_replace(
'/^OAUTH_/',
'', $key);
165 $key = preg_replace(
'/_ID$/',
'', $key);
166 if (preg_match(
'/^.*-/', $key)) {
167 $name = preg_replace(
'/^.*-/',
'', $key);
169 $name = $langs->trans(
"NoName");
171 $provider = preg_replace(
'/-.*$/',
'', $key);
172 $provider = ucfirst(strtolower($provider));
174 $oauthservices[$key] = $name.
" (".$provider.
")";
178if ($action ==
'edit') {
179 if ($conf->use_javascript_ajax) {
180 print
"\n".
'<script type="text/javascript">';
181 print
'jQuery(document).ready(function () {
182 function initfields()
184 if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'default\')
186 jQuery(".hideifdefault").hide();
190 jQuery(".hideifdefault").show();
193 if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'mail\')
195 jQuery(".drag").hide();
196 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val(0);
197 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").prop("disabled", true);
198 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val(0);
199 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").prop("disabled", true);
200 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val(0);
201 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").prop("disabled", true);
202 jQuery(".smtp_method").hide();
203 jQuery(".smtp_auth_method").hide();
207 jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").hide();
208 jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").hide();
209 jQuery("#smtp_server_mess").show();
210 jQuery("#smtp_port_mess").show();
214 jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").prop("disabled", true);
215 jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").prop("disabled", true);
216 jQuery("#smtp_server_mess").hide();
217 jQuery("#smtp_port_mess").hide();
222 if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'smtps\')
224 jQuery(".drag").show();
225 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_TLS_EMAILING').
');
226 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").removeAttr("disabled");
227 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS_EMAILING').
');
228 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").removeAttr("disabled");
229 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING').
');
230 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").removeAttr("disabled");
231 jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").removeAttr("disabled");
232 jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").removeAttr("disabled");
233 jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").show();
234 jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").show();
235 jQuery("#smtp_port_mess").hide();
236 jQuery("#smtp_server_mess").hide();
237 jQuery(".smtp_method").show();
238 jQuery(".smtp_auth_method").show();
240 if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'swiftmailer\')
242 jQuery(".drag").show();
243 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_TLS_EMAILING').
');
244 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").removeAttr("disabled");
245 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS_EMAILING').
');
246 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").removeAttr("disabled");
247 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING').
');
248 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").removeAttr("disabled");
249 jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").removeAttr("disabled");
250 jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").removeAttr("disabled");
251 jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").show();
252 jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").show();
253 jQuery("#smtp_server_mess").hide();
254 jQuery("#smtp_port_mess").hide();
255 jQuery(".smtp_method").show();
256 jQuery(".smtp_auth_method").show();
259 function change_smtp_auth_method() {
260 console.log(jQuery("#radio_pw").prop("checked"));
261 if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'smtps\' && jQuery("#radio_oauth").prop("checked")) {
262 jQuery(".smtp_oauth_service").show();
263 jQuery(".smtp_pw").hide();
264 } else if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'swiftmailer\' && jQuery("#radio_oauth").prop("checked")) {
265 jQuery(".smtp_oauth_service").show();
266 jQuery(".smtp_pw").hide();
267 } else if(jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'mail\' || jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'default\'){
268 jQuery(".smtp_oauth_service").hide();
269 jQuery(".smtp_pw").hide();
271 jQuery(".smtp_oauth_service").hide();
272 jQuery(".smtp_pw").show();
276 change_smtp_auth_method();
277 jQuery("#MAIN_MAIL_SENDMODE_EMAILING").change(function() {
279 change_smtp_auth_method();
281 jQuery("#radio_pw, #radio_oauth").change(function() {
282 change_smtp_auth_method();
284 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").change(function() {
285 if (jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val() == 1)
286 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val(0);
288 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val(0);
290 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").change(function() {
291 if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val() == 1)
292 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val(0);
294 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val(0);
297 print
'</script>'.
"\n";
300 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
301 print
'<input type="hidden" name="token" value="'.newToken().
'">';
302 print
'<input type="hidden" name="action" value="update">';
306 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
312 print
'<table class="noborder centpercent">';
313 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameters").
'</td><td></td></tr>';
317 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
320 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
321 print $form->selectarray(
'MAIN_MAIL_SENDMODE_EMAILING', $listofmethods, $conf->global->MAIN_MAIL_SENDMODE_EMAILING);
325 $text = $langs->trans(
"Undefined");
327 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
328 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
329 print
'<input type="hidden" name="MAIN_MAIL_SENDMODE_EMAILING" value="' .
getDolGlobalString(
'MAIN_MAIL_SENDMODE_EMAILING').
'">';
335 print
'<tr class="oddeven hideifdefault">';
336 if (!$conf->use_javascript_ajax && $linuxlike &&
getDolGlobalString(
'MAIN_MAIL_SENDMODE_EMAILING') ==
'mail') {
338 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
340 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
344 $mainserver = (
getDolGlobalString(
'MAIN_MAIL_SMTP_SERVER_EMAILING') ? $conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING :
'');
345 $smtpserver = ini_get(
'SMTP') ? ini_get(
'SMTP') : $langs->transnoentities(
"Undefined");
347 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
349 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER", $smtpserver);
353 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
354 print
'<input class="flat minwidth300" id="MAIN_MAIL_SMTP_SERVER_EMAILING" name="MAIN_MAIL_SMTP_SERVER_EMAILING" size="18" value="' . $mainserver .
'">';
355 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_EMAILING_sav" name="MAIN_MAIL_SMTP_SERVER_EMAILING_sav" value="' . $mainserver .
'">';
356 print
'<span id="smtp_server_mess" class="opacitymedium">' . $langs->trans(
"SeeLocalSendMailSetup") .
'</span>';
357 print
' <span class="opacitymedium smtp_method">' . $langs->trans(
"SeeLinkToOnlineDocumentation") .
'</span>';
359 $text = !empty($mainserver) ? $mainserver : $smtpserver;
360 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
361 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
362 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_EMAILING" name="MAIN_MAIL_SMTP_SERVER_EMAILING" value="' . $mainserver .
'">';
370 print
'<tr class="oddeven hideifdefault hideonmodemail"><td>';
371 if (!$conf->use_javascript_ajax && $linuxlike &&
getDolGlobalString(
'MAIN_MAIL_SENDMODE_EMAILING') ==
'mail') {
372 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
374 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
376 $mainport = (
getDolGlobalString(
'MAIN_MAIL_SMTP_PORT_EMAILING') ? $conf->global->MAIN_MAIL_SMTP_PORT_EMAILING :
'');
377 $smtpport = ini_get(
'smtp_port') ? ini_get(
'smtp_port') : $langs->transnoentities(
"Undefined");
379 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
381 print $langs->trans(
"MAIN_MAIL_SMTP_PORT", $smtpport);
385 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
386 print
'<input class="flat" id="MAIN_MAIL_SMTP_PORT_EMAILING" name="MAIN_MAIL_SMTP_PORT_EMAILING" size="3" value="' . $mainport .
'">';
387 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT_EMAILING_sav" name="MAIN_MAIL_SMTP_PORT_EMAILING_sav" value="' . $mainport .
'">';
388 print
'<span id="smtp_port_mess" class="opacitymedium">' . $langs->trans(
"SeeLocalSendMailSetup") .
'</span>';
390 $text = (!empty($mainport) ? $mainport : $smtpport);
391 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
392 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
393 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT_EMAILING" name="MAIN_MAIL_SMTP_PORT_EMAILING" value="' . $mainport .
'">';
399 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer')))) {
400 print
'<tr class="oddeven smtp_auth_method hideonmodemail hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE").
'</td><td>';
401 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
403 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' :
'').
'> ';
404 print
'<label for="radio_pw" >'.$langs->trans(
"UsePassword").
'</label>';
405 print
' ';
406 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' :
'').
'> ';
407 print
'<label for="radio_oauth" >'.$form->textwithpicto($langs->trans(
"UseOauth"), $langs->trans(
"OauthNotAvailableForAllAndHadToBeCreatedBefore")).
'</label>';
410 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
411 print $form->textwithpicto($langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE"), $htmltext, 1,
'superadmin');
412 print
'<input type="hidden" id="MAIN_MAIL_SMTPS_AUTH_TYPE" name="MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING" value="'.$value.
'">';
418 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer')))) {
419 $mainstmpid = (
getDolGlobalString(
'MAIN_MAIL_SMTPS_ID_EMAILING') ? $conf->global->MAIN_MAIL_SMTPS_ID_EMAILING :
'');
420 print
'<tr class="drag drop oddeven hideifdefault"><td>' . $langs->trans(
"MAIN_MAIL_SMTPS_ID") .
'</td><td>';
422 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
423 print
'<input class="flat" name="MAIN_MAIL_SMTPS_ID_EMAILING" size="32" value="' . $mainstmpid .
'">';
425 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
426 print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_ID_EMAILING, $htmltext, 1,
'superadmin');
427 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_ID_EMAILING" value="' . $mainstmpid .
'">';
433 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer')))) {
434 $mainsmtppw = (
getDolGlobalString(
'MAIN_MAIL_SMTPS_PW_EMAILING') ? $conf->global->MAIN_MAIL_SMTPS_PW_EMAILING :
'');
435 print
'<tr class="drag drop oddeven smtp_pw hideifdefault"><td>' . $langs->trans(
"MAIN_MAIL_SMTPS_PW") .
'</td><td>';
437 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
438 print
'<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW_EMAILING" size="32" value="' . $mainsmtppw .
'">';
440 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
441 print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_PW_EMAILING, $htmltext, 1,
'superadmin');
442 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_PW_EMAILING" value="' . $mainsmtppw .
'">';
448 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer')))) {
449 print
'<tr class="oddeven smtp_oauth_service hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE").
'</td><td>';
452 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
453 print $form->selectarray(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING', $oauthservices, $conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING);
457 $text = $langs->trans(
"Undefined");
459 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
460 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
461 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING" value="' .
getDolGlobalString(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING').
'">';
468 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
469 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer')))) {
470 if (function_exists(
'openssl_open')) {
471 print $form->selectyesno(
'MAIN_MAIL_EMAIL_TLS_EMAILING', (
getDolGlobalString(
'MAIN_MAIL_EMAIL_TLS_EMAILING') ? $conf->global->MAIN_MAIL_EMAIL_TLS_EMAILING : 0), 1);
473 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
476 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
481 print
'<tr class="oddeven hideifdefault hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
482 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer')))) {
483 if (function_exists(
'openssl_open')) {
484 print $form->selectyesno(
'MAIN_MAIL_EMAIL_STARTTLS_EMAILING', (
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS_EMAILING') ? $conf->global->MAIN_MAIL_EMAIL_STARTTLS_EMAILING : 0), 1);
486 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
489 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
494 print
'<tr class="oddeven hideifdefault hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
495 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer')))) {
496 if (function_exists(
'openssl_open')) {
497 print $form->selectyesno(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING', (
getDolGlobalString(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING') ? $conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING : 0), 1);
499 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
502 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
510 print $form->buttonsSaveCancel();
516 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
519 print
'<div class="div-table-responsive-no-min">';
520 print
'<table class="noborder centpercent">';
521 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameters").
'</td><td></td></tr>';
524 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
527 $text = $langs->trans(
"Undefined").img_warning();
530 print
'<span class="opacitymedium">'.$text.
'</span>';
541 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTP_SERVER", ini_get(
'SMTP') ? ini_get(
'SMTP') : $langs->transnoentities(
"Undefined")).
'</td><td>'.(
getDolGlobalString(
'MAIN_MAIL_SMTP_SERVER_EMAILING') ? $conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING :
'').
'</td></tr>';
548 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>'.(
getDolGlobalString(
'MAIN_MAIL_SMTP_PORT_EMAILING') ? $conf->global->MAIN_MAIL_SMTP_PORT_EMAILING :
'').
'</td></tr>';
552 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE_EMAILING'), array(
'smtps',
'swiftmailer'))) {
554 $text = ($authtype ===
"LOGIN") ? $langs->trans(
"UsePassword") : ($authtype ===
"XOAUTH2" ? $langs->trans(
"UseOauth") :
'') ;
555 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE").
'</td><td>'.$text.
'</td></tr>';
559 if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer'))) {
560 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>'.
getDolGlobalString(
'MAIN_MAIL_SMTPS_ID_EMAILING').
'</td></tr>';
564 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") {
565 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_PW").
'</td><td>'.preg_replace(
'/./',
'*',
getDolGlobalString(
'MAIN_MAIL_SMTPS_PW_EMAILING')).
'</td></tr>';
572 $text = $langs->trans(
"Undefined").img_warning();
574 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING").
'</td><td>'.$text.
'</td></tr>';
581 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
582 if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer'))) {
583 if (function_exists(
'openssl_open')) {
584 print
yn($conf->global->MAIN_MAIL_EMAIL_TLS_EMAILING);
586 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
589 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
598 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
599 if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer'))) {
600 if (function_exists(
'openssl_open')) {
601 print
yn($conf->global->MAIN_MAIL_EMAIL_STARTTLS_EMAILING);
603 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
606 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
615 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
616 if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer'))) {
617 if (function_exists(
'openssl_open')) {
620 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
623 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
646 print
info_admin($langs->trans(
"SendmailOptionMayHurtBuggedMTA"));
652 print
'<div class="tabsAction">';
654 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.newToken().
'">'.$langs->trans(
"Modify").
'</a>';
658 if (function_exists(
'fsockopen') && $port && $server) {
659 print
'<a class="butAction" href="' . $_SERVER[
"PHP_SELF"] .
'?action=testconnect">' . $langs->trans(
"DoTestServerAvailability") .
'</a>';
662 print
'<a class="butActionRefused classfortooltip" href="#" title="' . $langs->trans(
"FeatureNotAvailableOnLinux") .
'">' . $langs->trans(
"DoTestServerAvailability") .
'</a>';
665 print
'<a class="butAction" href="' . $_SERVER[
"PHP_SELF"] .
'?action=test&mode=init">' . $langs->trans(
"DoTestSend") .
'</a>';
667 if (isModEnabled(
'fckeditor')) {
668 print
'<a class="butAction" href="' . $_SERVER[
"PHP_SELF"] .
'?action=testhtml&mode=init">' . $langs->trans(
"DoTestSendHTML") .
'</a>';
675 if (
getDolGlobalString(
'MAIN_MAIL_SENDMODE_EMAILING') ==
'mail' && !in_array($action, array(
'testconnect',
'test',
'testhtml'))) {
676 $text = $langs->trans(
"WarningPHPMail");
681 if ($action ==
'testconnect') {
682 print
'<div id="formmailaftertstconnect" name="formmailaftertstconnect"></div>';
685 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
686 $mail =
new CMailFile(
'',
'',
'',
'', array(), array(), array(),
'',
'', 0,
'',
'',
'',
'', $trackid, $sendcontext);
688 $result = $mail->check_server_port($server, $port);
690 print
'<div class="ok">'.$langs->trans(
"ServerAvailableOnIPOrPort", $server, $port).
'</div>';
692 $errormsg = $langs->trans(
"ServerNotAvailableOnIPOrPort", $server, $port);
695 $errormsg .=
' - '.$mail->error;
704 if ($action ==
'test' || $action ==
'testhtml') {
705 print
'<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
706 print
load_fiche_titre($action ==
'testhtml' ? $langs->trans(
"DoTestSendHTML") : $langs->trans(
"DoTestSend"));
711 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
713 $formmail->trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
714 $formmail->fromname = (GETPOSTISSET(
'fromname') ?
GETPOST(
'fromname',
'restricthtml') : $conf->global->MAIN_MAIL_EMAIL_FROM);
715 $formmail->frommail = (GETPOSTISSET(
'frommail') ?
GETPOST(
'frommail',
'restricthtml') : $conf->global->MAIN_MAIL_EMAIL_FROM);
716 $formmail->fromid = $user->id;
717 $formmail->fromalsorobot = 1;
718 $formmail->withfromreadonly = 0;
719 $formmail->withsubstit = 0;
720 $formmail->withfrom = 1;
721 $formmail->witherrorsto = 1;
722 $formmail->withto = (GETPOSTISSET(
'sendto') ?
GETPOST(
'sendto',
'restricthtml') : ($user->email ? $user->email : 1));
723 $formmail->withtocc = (GETPOSTISSET(
'sendtocc') ?
GETPOST(
'sendtocc',
'restricthtml') : 1);
724 $formmail->withtoccc = (GETPOSTISSET(
'sendtoccc') ?
GETPOST(
'sendtoccc',
'restricthtml') : 1);
725 $formmail->withtopic = (GETPOSTISSET(
'subject') ?
GETPOST(
'subject') : $langs->trans(
"Test"));
726 $formmail->withtopicreadonly = 0;
727 $formmail->withfile = 2;
728 $formmail->withbody = (GETPOSTISSET(
'message') ?
GETPOST(
'message',
'restricthtml') : ($action ==
'testhtml' ? $langs->transnoentities(
"PredefinedMailTestHtml") : $langs->transnoentities(
"PredefinedMailTest")));
729 $formmail->withbodyreadonly = 0;
730 $formmail->withcancel = 1;
731 $formmail->withdeliveryreceipt = 1;
732 $formmail->withfckeditor = ($action ==
'testhtml' ? 1 : 0);
733 $formmail->ckeditortoolbar =
'dolibarr_mailings';
735 $formmail->substit = $substitutionarrayfortest;
737 $formmail->param[
"action"] =
"send";
738 $formmail->param[
"models"] =
"body";
739 $formmail->param[
"mailid"] = 0;
740 $formmail->param[
"returnurl"] = $_SERVER[
"PHP_SELF"];
743 if (
GETPOST(
"mode",
"aZ09") ==
'init') {
744 $formmail->clear_attached_files();
747 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 a 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', $nosalt=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.