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",
'alphanohtml'),
'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",
'alphanohtml'),
'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,
'', 0, 0,
'',
'',
'',
'mod-admin page-mails_emailing');
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 console.log("I choose php mail mode");
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 console.log("I choose smtps mail mode");
226 jQuery(".drag").show();
227 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_TLS_EMAILING').
');
228 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").removeAttr("disabled");
229 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS_EMAILING').
');
230 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").removeAttr("disabled");
231 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING').
');
232 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").removeAttr("disabled");
233 jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").removeAttr("disabled");
234 jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").removeAttr("disabled");
235 jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").show();
236 jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").show();
237 jQuery("#smtp_port_mess").hide();
238 jQuery("#smtp_server_mess").hide();
239 jQuery(".smtp_method").show();
240 jQuery(".smtp_auth_method").show();
242 if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'swiftmailer\')
244 console.log("I choose swiftmailer mail mode");
245 jQuery(".drag").show();
246 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_TLS_EMAILING').
');
247 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").removeAttr("disabled");
248 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS_EMAILING').
');
249 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").removeAttr("disabled");
250 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING').
');
251 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").removeAttr("disabled");
252 jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").removeAttr("disabled");
253 jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").removeAttr("disabled");
254 jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").show();
255 jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").show();
256 jQuery("#smtp_server_mess").hide();
257 jQuery("#smtp_port_mess").hide();
258 jQuery(".smtp_method").show();
259 jQuery(".smtp_auth_method").show();
262 function change_smtp_auth_method() {
263 console.log("Call smtp auth method");
264 if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'smtps\' && jQuery("#radio_oauth").prop("checked")) {
265 jQuery(".smtp_pw").hide();
266 jQuery(".smtp_oauth_service").show();
267 } else if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'swiftmailer\' && jQuery("#radio_oauth").prop("checked")) {
268 jQuery(".smtp_pw").hide();
269 jQuery(".smtp_oauth_service").show();
270 } else if(jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'mail\'){
271 jQuery(".smtp_pw").hide();
272 jQuery(".smtp_oauth_service").hide();
274 jQuery(".smtp_pw").show();
275 jQuery(".smtp_oauth_service").hide();
279 change_smtp_auth_method();
282 jQuery("#MAIN_MAIL_SENDMODE_EMAILING").change(function() {
283 change_smtp_auth_method();
286 jQuery("#radio_pw, #radio_plain, #radio_oauth").change(function() {
287 change_smtp_auth_method();
289 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").change(function() {
290 if (jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val() == 1)
291 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val(0);
293 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val(0);
295 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").change(function() {
296 if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val() == 1)
297 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val(0);
299 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val(0);
302 print
'</script>'.
"\n";
305 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
306 print
'<input type="hidden" name="token" value="'.newToken().
'">';
307 print
'<input type="hidden" name="action" value="update">';
311 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
317 print
'<table class="noborder centpercent">';
318 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameters").
'</td><td></td></tr>';
322 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
325 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
326 print $form->selectarray(
'MAIN_MAIL_SENDMODE_EMAILING', $listofmethods, $conf->global->MAIN_MAIL_SENDMODE_EMAILING);
330 $text = $langs->trans(
"Undefined");
332 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
333 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
334 print
'<input type="hidden" name="MAIN_MAIL_SENDMODE_EMAILING" value="' .
getDolGlobalString(
'MAIN_MAIL_SENDMODE_EMAILING').
'">';
340 print
'<tr class="oddeven hideifdefault">';
341 if (!$conf->use_javascript_ajax && $linuxlike &&
getDolGlobalString(
'MAIN_MAIL_SENDMODE_EMAILING') ==
'mail') {
343 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
345 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
349 $mainserver = (
getDolGlobalString(
'MAIN_MAIL_SMTP_SERVER_EMAILING') ? $conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING :
'');
350 $smtpserver = ini_get(
'SMTP') ? ini_get(
'SMTP') : $langs->transnoentities(
"Undefined");
352 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
354 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER", $smtpserver);
358 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
359 print
'<input class="flat minwidth300" id="MAIN_MAIL_SMTP_SERVER_EMAILING" name="MAIN_MAIL_SMTP_SERVER_EMAILING" size="18" value="' . $mainserver .
'">';
360 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_EMAILING_sav" name="MAIN_MAIL_SMTP_SERVER_EMAILING_sav" value="' . $mainserver .
'">';
361 print
'<span id="smtp_server_mess" class="opacitymedium">' . $langs->trans(
"SeeLocalSendMailSetup") .
'</span>';
362 print
' <span class="opacitymedium smtp_method">' . $langs->trans(
"SeeLinkToOnlineDocumentation") .
'</span>';
364 $text = !empty($mainserver) ? $mainserver : $smtpserver;
365 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
366 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
367 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_EMAILING" name="MAIN_MAIL_SMTP_SERVER_EMAILING" value="' . $mainserver .
'">';
375 print
'<tr class="oddeven hideifdefault hideonmodemail"><td>';
376 if (!$conf->use_javascript_ajax && $linuxlike &&
getDolGlobalString(
'MAIN_MAIL_SENDMODE_EMAILING') ==
'mail') {
377 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
379 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
381 $mainport = (
getDolGlobalString(
'MAIN_MAIL_SMTP_PORT_EMAILING') ? $conf->global->MAIN_MAIL_SMTP_PORT_EMAILING :
'');
382 $smtpport = ini_get(
'smtp_port') ? ini_get(
'smtp_port') : $langs->transnoentities(
"Undefined");
384 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
386 print $langs->trans(
"MAIN_MAIL_SMTP_PORT", $smtpport);
390 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
391 print
'<input class="flat" id="MAIN_MAIL_SMTP_PORT_EMAILING" name="MAIN_MAIL_SMTP_PORT_EMAILING" size="3" value="' . $mainport .
'">';
392 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT_EMAILING_sav" name="MAIN_MAIL_SMTP_PORT_EMAILING_sav" value="' . $mainport .
'">';
393 print
'<span id="smtp_port_mess" class="opacitymedium">' . $langs->trans(
"SeeLocalSendMailSetup") .
'</span>';
395 $text = (!empty($mainport) ? $mainport : $smtpport);
396 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
397 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
398 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT_EMAILING" name="MAIN_MAIL_SMTP_PORT_EMAILING" value="' . $mainport .
'">';
404 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer')))) {
405 print
'<tr class="oddeven smtp_auth_method hideonmodemail hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE").
'</td><td>';
406 $vartosmtpstype =
'MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING';
407 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
409 print
'<input type="radio" id="radio_pw" name="'.$vartosmtpstype.
'" value="LOGIN"'.(
getDolGlobalString($vartosmtpstype,
'LOGIN') ==
'LOGIN' ?
' checked' :
'').
'> ';
410 print
'<label for="radio_pw" >'.$langs->trans(
"UseAUTHLOGIN").
'</label>';
412 print
'<input type="radio" id="radio_plain" name="'.$vartosmtpstype.
'" value="PLAIN"'.(
getDolGlobalString($vartosmtpstype,
'PLAIN') ==
'PLAIN' ?
' checked' :
'').
'> ';
413 print
'<label for="radio_plain" >'.$langs->trans(
"UseAUTHPLAIN").
'</label>';
415 print
'<input type="radio" id="radio_oauth" name="'.$vartosmtpstype.
'" value="XOAUTH2"'.(
getDolGlobalString($vartosmtpstype) ==
'XOAUTH2' ?
' checked' :
'').(isModEnabled(
'oauth') ?
'' :
' disabled').
'> ';
416 print
'<label for="radio_oauth" >'.$form->textwithpicto($langs->trans(
"UseOauth"), $langs->trans(
"OauthNotAvailableForAllAndHadToBeCreatedBefore")).
'</label>';
417 if (!isModEnabled(
'oauth')) {
418 print
' <a href="'.DOL_URL_ROOT.
'/admin/modules.php?search_keyword=oauth">'.$langs->trans(
"EnableModuleX",
"OAuth").
'</a>';
420 print
' <a href="'.DOL_URL_ROOT.
'/admin/oauth.php">'.$langs->trans(
"SetupModuleX",
" OAuth").
'</a>';
424 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
425 print $form->textwithpicto($langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE"), $htmltext, 1,
'superadmin');
426 print
'<input type="hidden" id="MAIN_MAIL_SMTPS_AUTH_TYPE" name="MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING" value="'.$value.
'">';
432 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer')))) {
433 $mainstmpid = (
getDolGlobalString(
'MAIN_MAIL_SMTPS_ID_EMAILING') ? $conf->global->MAIN_MAIL_SMTPS_ID_EMAILING :
'');
434 print
'<tr class="drag drop oddeven hideifdefault"><td>' . $langs->trans(
"MAIN_MAIL_SMTPS_ID") .
'</td><td>';
436 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
437 print
'<input class="flat" name="MAIN_MAIL_SMTPS_ID_EMAILING" size="32" value="' . $mainstmpid .
'">';
439 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
440 print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_ID_EMAILING, $htmltext, 1,
'superadmin');
441 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_ID_EMAILING" value="' . $mainstmpid .
'">';
447 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer')))) {
448 $mainsmtppw = (
getDolGlobalString(
'MAIN_MAIL_SMTPS_PW_EMAILING') ? $conf->global->MAIN_MAIL_SMTPS_PW_EMAILING :
'');
449 print
'<tr class="drag drop oddeven smtp_pw hideifdefault"><td>' . $langs->trans(
"MAIN_MAIL_SMTPS_PW") .
'</td><td>';
451 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
452 print
'<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW_EMAILING" size="32" value="' . $mainsmtppw .
'">';
454 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
455 print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_PW_EMAILING, $htmltext, 1,
'superadmin');
456 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_PW_EMAILING" value="' . $mainsmtppw .
'">';
462 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer')))) {
463 print
'<tr class="oddeven smtp_oauth_service hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE").
'</td><td>';
466 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
468 print $form->selectarray(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING', $oauthservices, $conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING);
472 $text = $langs->trans(
"Undefined");
474 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
475 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
476 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING" value="' .
getDolGlobalString(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING').
'">';
483 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
484 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer')))) {
485 if (function_exists(
'openssl_open')) {
486 print $form->selectyesno(
'MAIN_MAIL_EMAIL_TLS_EMAILING', (
getDolGlobalString(
'MAIN_MAIL_EMAIL_TLS_EMAILING') ? $conf->global->MAIN_MAIL_EMAIL_TLS_EMAILING : 0), 1);
488 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
491 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
496 print
'<tr class="oddeven hideifdefault hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
497 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer')))) {
498 if (function_exists(
'openssl_open')) {
499 print $form->selectyesno(
'MAIN_MAIL_EMAIL_STARTTLS_EMAILING', (
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS_EMAILING') ? $conf->global->MAIN_MAIL_EMAIL_STARTTLS_EMAILING : 0), 1);
501 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
504 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
509 print
'<tr class="oddeven hideifdefault hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
510 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer')))) {
511 if (function_exists(
'openssl_open')) {
512 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);
514 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
517 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
525 print $form->buttonsSaveCancel();
531 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
534 print
'<div class="div-table-responsive-no-min">';
535 print
'<table class="noborder centpercent">';
536 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameters").
'</td><td></td></tr>';
539 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
542 $text = $langs->trans(
"Undefined").img_warning();
545 print
'<span class="opacitymedium">'.$text.
'</span>';
556 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>';
563 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>';
567 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE_EMAILING'), array(
'smtps',
'swiftmailer'))) {
570 if ($authtype ===
"LOGIN") {
571 $text = $langs->trans(
"UseAUTHLOGIN");
572 } elseif ($authtype ===
"PLAIN") {
573 $text = $langs->trans(
"UseAUTHPLAIN");
574 } elseif ($authtype ===
"XOAUTH2") {
575 $text = $langs->trans(
"UseOauth");
577 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE").
'</td><td>'.$text.
'</td></tr>';
581 if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer'))) {
582 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>'.
getDolGlobalString(
'MAIN_MAIL_SMTPS_ID_EMAILING').
'</td></tr>';
586 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") {
587 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_PW").
'</td><td>'.preg_replace(
'/./',
'*',
getDolGlobalString(
'MAIN_MAIL_SMTPS_PW_EMAILING')).
'</td></tr>';
594 $text = $langs->trans(
"Undefined").img_warning();
596 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING").
'</td><td>'.$text.
'</td></tr>';
603 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
604 if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer'))) {
605 if (function_exists(
'openssl_open')) {
608 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
611 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
620 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
621 if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer'))) {
622 if (function_exists(
'openssl_open')) {
625 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
628 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
637 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
638 if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer'))) {
639 if (function_exists(
'openssl_open')) {
642 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
645 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
668 print
info_admin($langs->trans(
"SendmailOptionMayHurtBuggedMTA"));
674 print
'<div class="tabsAction">';
676 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'">'.$langs->trans(
"Modify").
'</a>';
680 if (function_exists(
'fsockopen') && $port && $server) {
681 print
'<a class="butAction" href="' . $_SERVER[
"PHP_SELF"] .
'?action=testconnect">' . $langs->trans(
"DoTestServerAvailability") .
'</a>';
684 print
'<a class="butActionRefused classfortooltip" href="#" title="' . $langs->trans(
"FeatureNotAvailableOnLinux") .
'">' . $langs->trans(
"DoTestServerAvailability") .
'</a>';
687 print
'<a class="butAction" href="' . $_SERVER[
"PHP_SELF"] .
'?action=test&mode=init">' . $langs->trans(
"DoTestSend") .
'</a>';
689 if (isModEnabled(
'fckeditor')) {
690 print
'<a class="butAction" href="' . $_SERVER[
"PHP_SELF"] .
'?action=testhtml&mode=init">' . $langs->trans(
"DoTestSendHTML") .
'</a>';
697 if (
getDolGlobalString(
'MAIN_MAIL_SENDMODE_EMAILING') ==
'mail' && !in_array($action, array(
'testconnect',
'test',
'testhtml'))) {
698 $text = $langs->trans(
"WarningPHPMail", $listofmethods[
'mail'], $listofmethods[
'smtps']);
703 if ($action ==
'testconnect') {
704 print
'<div id="formmailaftertstconnect" name="formmailaftertstconnect"></div>';
707 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
708 $mail =
new CMailFile(
'',
'',
'',
'', array(), array(), array(),
'',
'', 0,
'',
'',
'',
'', $trackid, $sendcontext);
710 $result = $mail->check_server_port($server, $port);
712 print
'<div class="ok">'.$langs->trans(
"ServerAvailableOnIPOrPort", $server, $port).
'</div>';
714 $errormsg = $langs->trans(
"ServerNotAvailableOnIPOrPort", $server, $port);
717 $errormsg .=
' - '.$mail->error;
726 if ($action ==
'test' || $action ==
'testhtml') {
727 print
'<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
728 print
load_fiche_titre($action ==
'testhtml' ? $langs->trans(
"DoTestSendHTML") : $langs->trans(
"DoTestSend"));
733 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
735 $formmail->trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
736 $formmail->fromname = (GETPOSTISSET(
'fromname') ?
GETPOST(
'fromname',
'restricthtml') : $conf->global->MAIN_MAIL_EMAIL_FROM);
737 $formmail->frommail = (GETPOSTISSET(
'frommail') ?
GETPOST(
'frommail',
'restricthtml') : $conf->global->MAIN_MAIL_EMAIL_FROM);
738 $formmail->fromid = $user->id;
739 $formmail->fromalsorobot = 1;
740 $formmail->withfromreadonly = 0;
741 $formmail->withsubstit = 0;
742 $formmail->withfrom = 1;
743 $formmail->witherrorsto = 1;
744 $formmail->withto = (GETPOSTISSET(
'sendto') ?
GETPOST(
'sendto',
'restricthtml') : ($user->email ? $user->email : 1));
745 $formmail->withtocc = (GETPOSTISSET(
'sendtocc') ?
GETPOST(
'sendtocc',
'restricthtml') : 1);
746 $formmail->withtoccc = (GETPOSTISSET(
'sendtoccc') ?
GETPOST(
'sendtoccc',
'restricthtml') : 1);
747 $formmail->withtopic = (GETPOSTISSET(
'subject') ?
GETPOST(
'subject') : $langs->trans(
"Test"));
748 $formmail->withtopicreadonly = 0;
749 $formmail->withfile = 2;
750 $formmail->withbody = (GETPOSTISSET(
'message') ?
GETPOST(
'message',
'restricthtml') : ($action ==
'testhtml' ? $langs->transnoentities(
"PredefinedMailTestHtml") : $langs->transnoentities(
"PredefinedMailTest")));
751 $formmail->withbodyreadonly = 0;
752 $formmail->withcancel = 1;
753 $formmail->withdeliveryreceipt = 1;
754 $formmail->withfckeditor = ($action ==
'testhtml' ? 1 : 0);
755 $formmail->ckeditortoolbar =
'dolibarr_mailings';
757 $formmail->substit = $substitutionarrayfortest;
759 $formmail->param[
"action"] =
"send";
760 $formmail->param[
"models"] =
"body";
761 $formmail->param[
"mailid"] = 0;
762 $formmail->param[
"returnurl"] = $_SERVER[
"PHP_SELF"];
765 if (
GETPOST(
"mode",
"aZ09") ==
'init') {
766 $formmail->clear_attached_files();
769 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()
Empty header.
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
load_fiche_titre($title, $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.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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.
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.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
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.