28require
'../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
33$langs->loadLangs(array(
'companies',
'products',
'admin',
'mails',
'other',
'errors'));
35$action =
GETPOST(
'action',
'aZ09');
36$cancel =
GETPOST(
'cancel',
'aZ09');
38$usersignature = $user->signature;
40if ($action ==
'test' || $action ==
'send') {
44$substitutionarrayfortest = array(
45 '__ID__' =>
'TESTIdRecord',
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 '__LASTNAME__' =>
'RecipientLastname',
51 '__FIRSTNAME__' =>
'RecipientFirstname',
52 '__ADDRESS__' =>
'RecipientAddress',
53 '__ZIP__' =>
'RecipientZip',
54 '__TOWN_' =>
'RecipientTown',
55 '__COUNTRY__' =>
'RecipientCountry',
56 '__DOL_MAIN_URL_ROOT__' => DOL_MAIN_URL_ROOT,
61$listofmethods = array();
62$listofmethods[
'default'] = $langs->trans(
'DefaultOutgoingEmailSetup');
63$listofmethods[
'mail'] =
'PHP mail function';
65$listofmethods[
'smtps'] =
'SMTP/SMTPS socket library';
66if (version_compare(phpversion(),
'7.0',
'>=')) {
67 $listofmethods[
'swiftmailer'] =
'Swift Mailer socket library';
80if ($action ==
'update' && !$cancel) {
82 dolibarr_set_const($db,
"MAIN_MAIL_SENDMODE_PASSWORDRESET",
GETPOST(
"MAIN_MAIL_SENDMODE_PASSWORDRESET"),
'chaine', 0,
'', $conf->entity);
83 dolibarr_set_const($db,
"MAIN_MAIL_SMTP_PORT_PASSWORDRESET",
GETPOST(
"MAIN_MAIL_SMTP_PORT_PASSWORDRESET"),
'chaine', 0,
'', $conf->entity);
84 dolibarr_set_const($db,
"MAIN_MAIL_SMTP_SERVER_PASSWORDRESET",
GETPOST(
"MAIN_MAIL_SMTP_SERVER_PASSWORDRESET"),
'chaine', 0,
'', $conf->entity);
85 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_ID_PASSWORDRESET",
GETPOST(
"MAIN_MAIL_SMTPS_ID_PASSWORDRESET"),
'chaine', 0,
'', $conf->entity);
86 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_PW_PASSWORDRESET")) {
87 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_PW_PASSWORDRESET",
GETPOST(
"MAIN_MAIL_SMTPS_PW_PASSWORDRESET",
'password'),
'chaine', 0,
'', $conf->entity);
89 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_AUTH_TYPE_PASSWORDRESET")) {
90 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_AUTH_TYPE_PASSWORDRESET",
GETPOST(
"MAIN_MAIL_SMTPS_AUTH_TYPE_PASSWORDRESET",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
92 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE_PASSWORDRESET")) {
93 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_OAUTH_SERVICE_PASSWORDRESET",
GETPOST(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE_PASSWORDRESET",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
95 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_TLS_PASSWORDRESET",
GETPOST(
"MAIN_MAIL_EMAIL_TLS_PASSWORDRESET"),
'chaine', 0,
'', $conf->entity);
96 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_STARTTLS_PASSWORDRESET",
GETPOST(
"MAIN_MAIL_EMAIL_STARTTLS_PASSWORDRESET"),
'chaine', 0,
'', $conf->entity);
97 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_PASSWORDRESET",
GETPOST(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_PASSWORDRESET"),
'chaine', 0,
'', $conf->entity);
99 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?mainmenu=home&leftmenu=setup");
107$triggersendname =
'';
109$mode =
'emailfortest';
110$trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
111$sendcontext =
'ticket';
112include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
114if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'test') {
117if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'testhtml') {
118 $action =
'testhtml';
128$form =
new Form($db);
131if (preg_match(
'/^win/i', PHP_OS)) {
134if (preg_match(
'/^mac/i', PHP_OS)) {
139 $conf->global->MAIN_MAIL_SENDMODE_PASSWORDRESET =
'default';
141$port =
getDolGlobalInt(
'MAIN_MAIL_SMTP_PORT_PASSWORDRESET', (
int) ini_get(
'smtp_port'));
147 $server =
'127.0.0.1';
151$wikihelp =
'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails';
152llxHeader(
'', $langs->trans(
"Setup"), $wikihelp,
'', 0, 0,
'',
'',
'',
'mod-admin page-mails_passwordreset');
159$oauthservices = array();
161foreach ($conf->global as $key => $val) {
162 if (!empty($val) && preg_match(
'/^OAUTH_.*_ID$/', $key)) {
163 $key = preg_replace(
'/^OAUTH_/',
'', $key);
164 $key = preg_replace(
'/_ID$/',
'', $key);
165 if (preg_match(
'/^.*-/', $key)) {
166 $name = preg_replace(
'/^.*-/',
'', $key);
168 $name = $langs->trans(
"NoName");
170 $provider = preg_replace(
'/-.*$/',
'', $key);
171 $provider = ucfirst(strtolower($provider));
173 $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_PASSWORDRESET").val()==\'default\')
186 jQuery(".hideifdefault").hide();
190 jQuery(".hideifdefault").show();
193 if (jQuery("#MAIN_MAIL_SENDMODE_PASSWORDRESET").val()==\'mail\')
195 console.log("I choose php mail mode");
196 jQuery(".drag").hide();
197 jQuery("#MAIN_MAIL_EMAIL_TLS_PASSWORDRESET").val(0);
198 jQuery("#MAIN_MAIL_EMAIL_TLS_PASSWORDRESET").prop("disabled", true);
199 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_PASSWORDRESET").val(0);
200 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_PASSWORDRESET").prop("disabled", true);
201 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_PASSWORDRESET").val(0);
202 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_PASSWORDRESET").prop("disabled", true);
203 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_PASSWORDRESET").val(0);
204 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_PASSWORDRESET").prop("disabled", true);
205 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN_PASSWORDRESET").prop("disabled", true);
206 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR_PASSWORDRESET").prop("disabled", true);
207 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY_PASSWORDRESET").prop("disabled", true);
208 jQuery(".smtp_method").hide();
209 jQuery(".dkim").hide();
210 jQuery(".smtp_auth_method").hide();
214 jQuery("#MAIN_MAIL_SMTP_SERVER_PASSWORDRESET").hide();
215 jQuery("#MAIN_MAIL_SMTP_PORT_PASSWORDRESET").hide();
216 jQuery("#smtp_server_mess").show();
217 jQuery("#smtp_port_mess").show();
221 jQuery("#MAIN_MAIL_SMTP_SERVER_PASSWORDRESET").prop("disabled", true);
222 jQuery("#MAIN_MAIL_SMTP_PORT_PASSWORDRESET").prop("disabled", true);
223 jQuery("#smtp_server_mess").hide();
224 jQuery("#smtp_port_mess").hide();
229 if (jQuery("#MAIN_MAIL_SENDMODE_PASSWORDRESET").val()==\'smtps\')
231 console.log("I choose smtps mail mode");
232 jQuery(".drag").show();
233 jQuery("#MAIN_MAIL_EMAIL_TLS_PASSWORDRESET").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_TLS_PASSWORDRESET').
');
234 jQuery("#MAIN_MAIL_EMAIL_TLS_PASSWORDRESET").removeAttr("disabled");
235 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_PASSWORDRESET").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS_PASSWORDRESET').
');
236 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_PASSWORDRESET").removeAttr("disabled");
237 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_PASSWORDRESET").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_PASSWORDRESET').
');
238 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_PASSWORDRESET").removeAttr("disabled");
239 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_PASSWORDRESET").val(0);
240 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_PASSWORDRESET").prop("disabled", true);
241 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN_PASSWORDRESET").prop("disabled", true);
242 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR_PASSWORDRESET").prop("disabled", true);
243 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY_PASSWORDRESET").prop("disabled", true);
244 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN_PASSWORDRESET").hide();
245 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR_PASSWORDRESET").hide();
246 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY_PASSWORDRESET").hide();
247 jQuery("#MAIN_MAIL_SMTP_SERVER_PASSWORDRESET").removeAttr("disabled");
248 jQuery("#MAIN_MAIL_SMTP_PORT_PASSWORDRESET").removeAttr("disabled");
249 jQuery("#MAIN_MAIL_SMTP_SERVER_PASSWORDRESET").show();
250 jQuery("#MAIN_MAIL_SMTP_PORT_PASSWORDRESET").show();
251 jQuery("#smtp_server_mess").hide();
252 jQuery("#smtp_port_mess").hide();
253 jQuery(".smtp_method").show();
254 jQuery(".dkim").hide();
255 jQuery(".smtp_auth_method").show();
257 if (jQuery("#MAIN_MAIL_SENDMODE_PASSWORDRESET").val()==\'swiftmailer\')
259 console.log("I choose swiftmailer mail mode");
260 jQuery(".drag").show();
261 jQuery("#MAIN_MAIL_EMAIL_TLS_PASSWORDRESET").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_TLS_PASSWORDRESET').
');
262 jQuery("#MAIN_MAIL_EMAIL_TLS_PASSWORDRESET").removeAttr("disabled");
263 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_PASSWORDRESET").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS_PASSWORDRESET').
');
264 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_PASSWORDRESET").removeAttr("disabled");
265 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_PASSWORDRESET").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_PASSWORDRESET').
');
266 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_PASSWORDRESET").removeAttr("disabled");
267 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_PASSWORDRESET").val(0);
268 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_PASSWORDRESET").prop("disabled", true);
269 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN_PASSWORDRESET").prop("disabled", true);
270 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR_PASSWORDRESET").prop("disabled", true);
271 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY_PASSWORDRESET").prop("disabled", true);
272 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN_PASSWORDRESET").hide();
273 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR_PASSWORDRESET").hide();
274 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY_PASSWORDRESET").hide();
275 jQuery("#MAIN_MAIL_SMTP_SERVER_PASSWORDRESET").removeAttr("disabled");
276 jQuery("#MAIN_MAIL_SMTP_PORT_PASSWORDRESET").removeAttr("disabled");
277 jQuery("#MAIN_MAIL_SMTP_SERVER_PASSWORDRESET").show();
278 jQuery("#MAIN_MAIL_SMTP_PORT_PASSWORDRESET").show();
279 jQuery("#smtp_server_mess").hide();
280 jQuery("#smtp_port_mess").hide();
281 jQuery(".smtp_method").show();
282 jQuery(".dkim").show();
283 jQuery(".smtp_auth_method").show();
286 function change_smtp_auth_method() {
287 console.log("Call smtp auth method");
288 if (jQuery("#MAIN_MAIL_SENDMODE_PASSWORDRESET").val()==\'smtps\') {
289 if (jQuery("#radio_oauth").prop("checked")) {
290 jQuery(".smtp_pw").hide();
291 jQuery(".smtp_oauth_service").show();
293 jQuery(".smtp_pw").show();
294 jQuery(".smtp_oauth_service").hide();
296 } else if (jQuery("#MAIN_MAIL_SENDMODE_PASSWORDRESET").val()==\'swiftmailer\') {
297 if (jQuery("#radio_oauth").prop("checked")) {
298 jQuery(".smtp_pw").hide();
299 jQuery(".smtp_oauth_service").show();
301 jQuery(".smtp_pw").show();
302 jQuery(".smtp_oauth_service").hide();
305 jQuery(".smtp_pw").hide();
306 jQuery(".smtp_oauth_service").hide();
311 change_smtp_auth_method();
313 jQuery("#MAIN_MAIL_SENDMODE_PASSWORDRESET").change(function() {
315 change_smtp_auth_method();
317 jQuery("#radio_pw, #radio_plain, #radio_oauth").change(function() {
318 change_smtp_auth_method();
320 jQuery("#MAIN_MAIL_EMAIL_TLS").change(function() {
321 if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS_PASSWORDRESET").val() == 1)
322 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_PASSWORDRESET").val(0);
324 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_PASSWORDRESET").change(function() {
325 if (jQuery("#MAIN_MAIL_EMAIL_TLS_PASSWORDRESET").val() == 1)
326 jQuery("#MAIN_MAIL_EMAIL_TLS_PASSWORDRESET").val(0);
329 print
'</script>'.
"\n";
332 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
333 print
'<input type="hidden" name="token" value="'.newToken().
'">';
334 print
'<input type="hidden" name="action" value="update">';
338 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
344 print
'<table class="noborder centpercent">';
345 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameters").
'</td><td></td></tr>';
349 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
352 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
353 print $form->selectarray(
'MAIN_MAIL_SENDMODE_PASSWORDRESET', $listofmethods, $conf->global->MAIN_MAIL_SENDMODE_PASSWORDRESET);
357 $text = $langs->trans(
"Undefined");
359 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
360 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
361 print
'<input type="hidden" name="MAIN_MAIL_SENDMODE_PASSWORDRESET" value="' .
getDolGlobalString(
'MAIN_MAIL_SENDMODE_PASSWORDRESET').
'">';
367 print
'<tr class="oddeven hideifdefault">';
368 if (!$conf->use_javascript_ajax && $linuxlike &&
getDolGlobalString(
'MAIN_MAIL_SENDMODE_PASSWORDRESET') ==
'mail') {
370 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
372 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
376 $mainserver = (
getDolGlobalString(
'MAIN_MAIL_SMTP_SERVER_PASSWORDRESET') ? $conf->global->MAIN_MAIL_SMTP_SERVER_PASSWORDRESET :
'');
377 $smtpserver = ini_get(
'SMTP') ? ini_get(
'SMTP') : $langs->transnoentities(
"Undefined");
379 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
381 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER", $smtpserver);
385 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
386 print
'<input class="flat minwidth300" id="MAIN_MAIL_SMTP_SERVER_PASSWORDRESET" name="MAIN_MAIL_SMTP_SERVER_PASSWORDRESET" size="18" value="'.$mainserver.
'">';
387 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_PASSWORDRESET_sav" name="MAIN_MAIL_SMTP_SERVER_PASSWORDRESET_sav" value="'.$mainserver.
'">';
388 print
'<span id="smtp_server_mess" class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
389 print
' <span class="opacitymedium smtp_method">' . $langs->trans(
"SeeLinkToOnlineDocumentation") .
'</span>';
391 $text = !empty($mainserver) ? $mainserver : $smtpserver;
392 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
393 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
394 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_PASSWORDRESET" name="MAIN_MAIL_SMTP_SERVER_PASSWORDRESET" value="'.$mainserver.
'">';
402 print
'<tr class="oddeven hideifdefault hideonmodemail"><td>';
403 if (!$conf->use_javascript_ajax && $linuxlike &&
getDolGlobalString(
'MAIN_MAIL_SENDMODE_PASSWORDRESET') ==
'mail') {
404 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
406 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
408 $mainport = (
getDolGlobalString(
'MAIN_MAIL_SMTP_PORT_PASSWORDRESET') ? $conf->global->MAIN_MAIL_SMTP_PORT_PASSWORDRESET :
'');
409 $smtpport = ini_get(
'smtp_port') ? ini_get(
'smtp_port') : $langs->transnoentities(
"Undefined");
411 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
413 print $langs->trans(
"MAIN_MAIL_SMTP_PORT", $smtpport);
417 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
418 print
'<input class="flat" id="MAIN_MAIL_SMTP_PORT_PASSWORDRESET" name="MAIN_MAIL_SMTP_PORT_PASSWORDRESET" size="3" value="'.$mainport.
'">';
419 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT_PASSWORDRESET_sav" name="MAIN_MAIL_SMTP_PORT_PASSWORDRESET_sav" value="'.$mainport.
'">';
420 print
'<span id="smtp_port_mess" class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
422 $text = (!empty($mainport) ? $mainport : $smtpport);
423 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
424 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
425 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT_PASSWORDRESET" name="MAIN_MAIL_SMTP_PORT_PASSWORDRESET" value="'.$mainport.
'">';
431 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_PASSWORDRESET) && in_array($conf->global->MAIN_MAIL_SENDMODE_PASSWORDRESET, array(
'smtps',
'swiftmailer')))) {
432 print
'<tr class="oddeven smtp_auth_method hideifdefault hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE").
'</td><td>';
433 $vartosmtpstype =
'MAIN_MAIL_SMTPS_AUTH_TYPE_PASSWORDRESET';
434 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
436 print
'<input type="radio" id="radio_pw" name="'.$vartosmtpstype.
'" value="LOGIN"'.(
getDolGlobalString($vartosmtpstype,
'LOGIN') ==
'LOGIN' ?
' checked' :
'').
'> ';
437 print
'<label for="radio_pw" >'.$langs->trans(
"UseAUTHLOGIN").
'</label>';
439 print
'<input type="radio" id="radio_plain" name="'.$vartosmtpstype.
'" value="PLAIN"'.(
getDolGlobalString($vartosmtpstype,
'PLAIN') ==
'PLAIN' ?
' checked' :
'').
'> ';
440 print
'<label for="radio_plain" >'.$langs->trans(
"UseAUTHPLAIN").
'</label>';
442 print
'<input type="radio" id="radio_oauth" name="'.$vartosmtpstype.
'" value="XOAUTH2"'.(
getDolGlobalString($vartosmtpstype) ==
'XOAUTH2' ?
' checked' :
'').(isModEnabled(
'oauth') ?
'' :
' disabled').
'> ';
443 print
'<label for="radio_oauth" >'.$form->textwithpicto($langs->trans(
"UseOauth"), $langs->trans(
"OauthNotAvailableForAllAndHadToBeCreatedBefore")).
'</label>';
444 if (!isModEnabled(
'oauth')) {
445 print
' <a href="'.DOL_URL_ROOT.
'/admin/modules.php?search_keyword=oauth">'.$langs->trans(
"EnableModuleX",
"OAuth").
'</a>';
447 print
' <a href="'.DOL_URL_ROOT.
'/admin/oauth.php">'.$langs->trans(
"SetupModuleX",
" OAuth").
'</a>';
451 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
452 print $form->textwithpicto($langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE"), $htmltext, 1,
'superadmin');
453 print
'<input type="hidden" id="MAIN_MAIL_SMTPS_AUTH_TYPE" name="MAIN_MAIL_SMTPS_AUTH_TYPE_PASSWORDRESET" value="'.$value.
'">';
459 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_PASSWORDRESET) && in_array($conf->global->MAIN_MAIL_SENDMODE_PASSWORDRESET, array(
'smtps',
'swiftmailer')))) {
460 $mainstmpid = (
getDolGlobalString(
'MAIN_MAIL_SMTPS_ID_PASSWORDRESET') ? $conf->global->MAIN_MAIL_SMTPS_ID_PASSWORDRESET :
'');
461 print
'<tr class="drag drop oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>';
463 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
464 print
'<input class="flat" name="MAIN_MAIL_SMTPS_ID_PASSWORDRESET" size="32" value="'.$mainstmpid.
'">';
466 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
467 print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_ID_PASSWORDRESET, $htmltext, 1,
'superadmin');
468 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_ID_PASSWORDRESET" value="'.$mainstmpid.
'">';
474 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_PASSWORDRESET) && in_array($conf->global->MAIN_MAIL_SENDMODE_PASSWORDRESET, array(
'smtps',
'swiftmailer')))) {
476 print
'<tr class="drag drop oddeven smtp_pw hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_PW").
'</td><td>';
478 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
479 print
'<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW_PASSWORDRESET" size="32" value="'.$mainsmtppw.
'">';
481 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
482 print $form->textwithpicto(
getDolGlobalString(
'MAIN_MAIL_SMTPS_PW_PASSWORDRESET'), $htmltext, 1,
'superadmin');
483 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_PW_PASSWORDRESET" value="'.$mainsmtppw.
'">';
489 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_PASSWORDRESET) && in_array($conf->global->MAIN_MAIL_SENDMODE_PASSWORDRESET, array(
'smtps',
'swiftmailer')))) {
490 print
'<tr class="oddeven smtp_oauth_service hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE").
'</td><td>';
492 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
493 print $form->selectarray(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE_PASSWORDRESET', $oauthservices, $conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE_PASSWORDRESET);
495 $text = $oauthservices[
getDolGlobalString(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE_PASSWORDRESET')];
497 $text = $langs->trans(
"Undefined");
499 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
500 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
501 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_OAUTH_SERVICE_PASSWORDRESET" value="' .
getDolGlobalString(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE_PASSWORDRESET').
'">';
508 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
509 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_PASSWORDRESET) && in_array($conf->global->MAIN_MAIL_SENDMODE_PASSWORDRESET, array(
'smtps',
'swiftmailer')))) {
510 if (function_exists(
'openssl_open')) {
511 print $form->selectyesno(
'MAIN_MAIL_EMAIL_TLS_PASSWORDRESET', (
getDolGlobalString(
'MAIN_MAIL_EMAIL_TLS_PASSWORDRESET') ? $conf->global->MAIN_MAIL_EMAIL_TLS_PASSWORDRESET : 0), 1);
513 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
516 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
522 print
'<tr class="oddeven hideifdefault hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
523 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_PASSWORDRESET) && in_array($conf->global->MAIN_MAIL_SENDMODE_PASSWORDRESET, array(
'smtps',
'swiftmailer')))) {
524 if (function_exists(
'openssl_open')) {
525 print $form->selectyesno(
'MAIN_MAIL_EMAIL_STARTTLS_PASSWORDRESET', (
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS_PASSWORDRESET') ? $conf->global->MAIN_MAIL_EMAIL_STARTTLS_PASSWORDRESET : 0), 1);
527 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
530 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
535 print
'<tr class="oddeven hideifdefault hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
536 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_PASSWORDRESET) && in_array($conf->global->MAIN_MAIL_SENDMODE_PASSWORDRESET, array(
'smtps',
'swiftmailer')))) {
537 if (function_exists(
'openssl_open')) {
538 print $form->selectyesno(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_PASSWORDRESET', (
getDolGlobalString(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_PASSWORDRESET') ? $conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_PASSWORDRESET : 0), 1);
540 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
543 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
551 print $form->buttonsSaveCancel();
557 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
560 print
'<div class="div-table-responsive-no-min">';
561 print
'<table class="noborder centpercent">';
562 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameters").
'</td><td></td></tr>';
565 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
568 $text = $langs->trans(
"Undefined").img_warning();
571 print
'<span class="opacitymedium">'.$text.
'</span>';
579 if ($linuxlike && (
getDolGlobalString(
'MAIN_MAIL_SENDMODE_PASSWORDRESET') ==
'mail')) {
582 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_PASSWORDRESET') ? $conf->global->MAIN_MAIL_SMTP_SERVER_PASSWORDRESET :
'').
'</td></tr>';
586 if ($linuxlike && (
getDolGlobalString(
'MAIN_MAIL_SENDMODE_PASSWORDRESET') ==
'mail')) {
589 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_PASSWORDRESET') ? $conf->global->MAIN_MAIL_SMTP_PORT_PASSWORDRESET :
'').
'</td></tr>';
593 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE_PASSWORDRESET'), array(
'smtps',
'swiftmailer'))) {
596 if ($authtype ===
"LOGIN") {
597 $text = $langs->trans(
"UseAUTHLOGIN");
598 } elseif ($authtype ===
"PLAIN") {
599 $text = $langs->trans(
"UseAUTHPLAIN");
600 } elseif ($authtype ===
"XOAUTH2") {
601 $text = $langs->trans(
"UseOauth");
603 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE").
'</td><td>'.$text.
'</td></tr>';
607 if (isset($conf->global->MAIN_MAIL_SENDMODE_PASSWORDRESET) && in_array($conf->global->MAIN_MAIL_SENDMODE_PASSWORDRESET, array(
'smtps',
'swiftmailer'))) {
608 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>' .
getDolGlobalString(
'MAIN_MAIL_SMTPS_ID_PASSWORDRESET').
'</td></tr>';
612 if (isset($conf->global->MAIN_MAIL_SENDMODE_PASSWORDRESET) && in_array($conf->global->MAIN_MAIL_SENDMODE_PASSWORDRESET, array(
'smtps',
'swiftmailer')) &&
getDolGlobalString(
'MAIN_MAIL_SMTPS_AUTH_TYPE_PASSWORDRESET') !=
"XOAUTH2") {
613 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_PW").
'</td><td>'.preg_replace(
'/./',
'*',
getDolGlobalString(
'MAIN_MAIL_SMTPS_PW_PASSWORDRESET')).
'</td></tr>';
617 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE_PASSWORDRESET'), array(
'smtps',
'swiftmailer')) &&
getDolGlobalString(
'MAIN_MAIL_SMTPS_AUTH_TYPE_PASSWORDRESET') ===
"XOAUTH2") {
618 $text = $oauthservices[
getDolGlobalString(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE_PASSWORDRESET')];
620 $text = $langs->trans(
"Undefined").img_warning();
622 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE").
'</td><td>'.$text.
'</td></tr>';
629 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
630 if (isset($conf->global->MAIN_MAIL_SENDMODE_PASSWORDRESET) && in_array($conf->global->MAIN_MAIL_SENDMODE_PASSWORDRESET, array(
'smtps',
'swiftmailer'))) {
631 if (function_exists(
'openssl_open')) {
634 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
637 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
646 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
647 if (isset($conf->global->MAIN_MAIL_SENDMODE_PASSWORDRESET) && in_array($conf->global->MAIN_MAIL_SENDMODE_PASSWORDRESET, array(
'smtps',
'swiftmailer'))) {
648 if (function_exists(
'openssl_open')) {
651 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
654 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
663 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
664 if (isset($conf->global->MAIN_MAIL_SENDMODE_PASSWORDRESET) && in_array($conf->global->MAIN_MAIL_SENDMODE_PASSWORDRESET, array(
'smtps',
'swiftmailer'))) {
665 if (function_exists(
'openssl_open')) {
666 print
yn(
getDolGlobalInt(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_PASSWORDRESET'));
668 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
671 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
696 print
info_admin($langs->trans(
"SendmailOptionMayHurtBuggedMTA"));
702 print
'<div class="tabsAction">';
704 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'">'.$langs->trans(
"Modify").
'</a>';
707 if (
getDolGlobalString(
'MAIN_MAIL_SENDMODE_PASSWORDRESET') !=
'mail' || !$linuxlike) {
708 if (function_exists(
'fsockopen') && $port && $server) {
709 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testconnect">'.$langs->trans(
"DoTestServerAvailability").
'</a>';
712 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"FeatureNotAvailableOnLinux").
'">'.$langs->trans(
"DoTestServerAvailability").
'</a>';
715 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=test&mode=init">'.$langs->trans(
"DoTestSend").
'</a>';
717 if (isModEnabled(
'fckeditor')) {
718 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testhtml&mode=init">'.$langs->trans(
"DoTestSendHTML").
'</a>';
725 if (
getDolGlobalString(
'MAIN_MAIL_SENDMODE_PASSWORDRESET') ==
'mail' && !in_array($action, array(
'testconnect',
'test',
'testhtml'))) {
726 $text = $langs->trans(
"WarningPHPMail");
731 if ($action ==
'testconnect') {
732 print
'<div id="formmailaftertstconnect" name="formmailaftertstconnect"></div>';
735 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
736 $mail =
new CMailFile(
'',
'',
'',
'', array(), array(), array(),
'',
'', 0, 0,
'',
'',
'', $trackid, $sendcontext);
738 $result = $mail->check_server_port($server, $port);
740 print
'<div class="ok">'.$langs->trans(
"ServerAvailableOnIPOrPort", $server, $port).
'</div>';
742 $errormsg = $langs->trans(
"ServerNotAvailableOnIPOrPort", $server, $port);
745 $errormsg .=
' - '.$mail->error;
754 if ($action ==
'test' || $action ==
'testhtml') {
755 print
'<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
756 print
load_fiche_titre($action ==
'testhtml' ? $langs->trans(
"DoTestSendHTML") : $langs->trans(
"DoTestSend"));
761 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
763 $formmail->fromname = (GETPOSTISSET(
'fromname') ?
GETPOST(
'fromname',
'restricthtml') :
getDolGlobalString(
'MAIN_MAIL_EMAIL_FROM'));
764 $formmail->frommail = (GETPOSTISSET(
'frommail') ?
GETPOST(
'frommail',
'restricthtml') :
getDolGlobalString(
'MAIN_MAIL_EMAIL_FROM'));
765 $formmail->trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
766 $formmail->fromid = $user->id;
767 $formmail->fromalsorobot = 1;
768 $formmail->withfromreadonly = 0;
769 $formmail->withsubstit = 0;
770 $formmail->withfrom = 1;
771 $formmail->witherrorsto = 1;
772 $formmail->withto = (GETPOSTISSET(
'sendto') ?
GETPOST(
'sendto',
'restricthtml') : ($user->
email ? $user->
email : 1));
773 $formmail->withtocc = (GETPOSTISSET(
'sendtocc') ?
GETPOST(
'sendtocc',
'restricthtml') : 1);
774 $formmail->withtoccc = (GETPOSTISSET(
'sendtoccc') ?
GETPOST(
'sendtoccc',
'restricthtml') : 1);
775 $formmail->withtopic = (GETPOSTISSET(
'subject') ?
GETPOST(
'subject') : $langs->trans(
"Test"));
776 $formmail->withtopicreadonly = 0;
777 $formmail->withfile = 2;
778 $formmail->withbody = (GETPOSTISSET(
'message') ?
GETPOST(
'message',
'restricthtml') : ($action ==
'testhtml' ? $langs->transnoentities(
"PredefinedMailTestHtml") : $langs->transnoentities(
"PredefinedMailTest")));
779 $formmail->withbodyreadonly = 0;
780 $formmail->withcancel = 1;
781 $formmail->withdeliveryreceipt = 1;
782 $formmail->withfckeditor = ($action ==
'testhtml' ? 1 : 0);
783 $formmail->ckeditortoolbar =
'dolibarr_mailings';
785 $formmail->substit = $substitutionarrayfortest;
787 $formmail->param[
"action"] =
"send";
788 $formmail->param[
"models"] =
"body";
789 $formmail->param[
"mailid"] = 0;
790 $formmail->param[
"returnurl"] = $_SERVER[
"PHP_SELF"];
793 if (
GETPOST(
"mode",
"aZ09") ==
'init') {
794 $formmail->clear_attached_files();
797 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 information.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as p label as s rowid as s nom as s email
Sender: Who sends the email ("Sender" has sent emails on behalf of "From").
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
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.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.