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__' =>
'RecipientIdRecord',
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 :
''),
51 '__LASTNAME__' =>
'RecipientLastname',
52 '__FIRSTNAME__' =>
'RecipientFirstname',
53 '__ADDRESS__' =>
'RecipientAddress',
54 '__ZIP__' =>
'RecipientZip',
55 '__TOWN_' =>
'RecipientTown',
56 '__COUNTRY__' =>
'RecipientCountry',
57 '__DOL_MAIN_URL_ROOT__' => DOL_MAIN_URL_ROOT,
58 '__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"/>'
63$listofmethods = array();
64$listofmethods[
'default'] = $langs->trans(
'DefaultOutgoingEmailSetup');
65$listofmethods[
'mail'] =
'PHP mail function';
67$listofmethods[
'smtps'] =
'SMTP/SMTPS socket library';
68if (version_compare(phpversion(),
'7.0',
'>=')) {
69 $listofmethods[
'swiftmailer'] =
'Swift Mailer socket library';
82if ($action ==
'update' && !$cancel) {
84 dolibarr_set_const($db,
"MAIN_MAIL_SENDMODE_EMAILING",
GETPOST(
"MAIN_MAIL_SENDMODE_EMAILING"),
'chaine', 0,
'', $conf->entity);
85 dolibarr_set_const($db,
"MAIN_MAIL_SMTP_PORT_EMAILING",
GETPOST(
"MAIN_MAIL_SMTP_PORT_EMAILING"),
'chaine', 0,
'', $conf->entity);
86 dolibarr_set_const($db,
"MAIN_MAIL_SMTP_SERVER_EMAILING",
GETPOST(
"MAIN_MAIL_SMTP_SERVER_EMAILING"),
'chaine', 0,
'', $conf->entity);
87 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_ID_EMAILING",
GETPOST(
"MAIN_MAIL_SMTPS_ID_EMAILING"),
'chaine', 0,
'', $conf->entity);
88 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_PW_EMAILING")) {
89 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_PW_EMAILING",
GETPOST(
"MAIN_MAIL_SMTPS_PW_EMAILING",
'password'),
'chaine', 0,
'', $conf->entity);
91 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING")) {
92 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING",
GETPOST(
"MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
94 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING")) {
95 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING",
GETPOST(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
97 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_TLS_EMAILING",
GETPOST(
"MAIN_MAIL_EMAIL_TLS_EMAILING"),
'chaine', 0,
'', $conf->entity);
98 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_STARTTLS_EMAILING",
GETPOST(
"MAIN_MAIL_EMAIL_STARTTLS_EMAILING"),
'chaine', 0,
'', $conf->entity);
99 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING",
GETPOST(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING"),
'chaine', 0,
'', $conf->entity);
101 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?mainmenu=home&leftmenu=setup");
109$triggersendname =
'';
111$mode =
'emailfortest';
112$trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
113$sendcontext =
'emailing';
114include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
116if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'test') {
119if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'testhtml') {
120 $action =
'testhtml';
130$form =
new Form($db);
133if (preg_match(
'/^win/i', PHP_OS)) {
136if (preg_match(
'/^mac/i', PHP_OS)) {
141 $conf->global->MAIN_MAIL_SENDMODE_EMAILING =
'default';
143$port =
getDolGlobalInt(
'MAIN_MAIL_SMTP_PORT_EMAILING', (
int) ini_get(
'smtp_port'));
149 $server =
'127.0.0.1';
153$wikihelp =
'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails';
154llxHeader(
'', $langs->trans(
"Setup"), $wikihelp,
'', 0, 0,
'',
'',
'',
'mod-admin page-mails_emailing');
161$oauthservices = array();
163foreach ($conf->global as $key => $val) {
164 if (!empty($val) && preg_match(
'/^OAUTH_.*_ID$/', $key)) {
165 $key = preg_replace(
'/^OAUTH_/',
'', $key);
166 $key = preg_replace(
'/_ID$/',
'', $key);
167 if (preg_match(
'/^.*-/', $key)) {
168 $name = preg_replace(
'/^.*-/',
'', $key);
170 $name = $langs->trans(
"NoName");
172 $provider = preg_replace(
'/-.*$/',
'', $key);
173 $provider = ucfirst(strtolower($provider));
175 $oauthservices[$key] = $name.
" (".$provider.
")";
179if ($action ==
'edit') {
180 if ($conf->use_javascript_ajax) {
181 print
"\n".
'<script type="text/javascript">';
182 print
'jQuery(document).ready(function () {
183 function initfields()
185 if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'default\')
187 jQuery(".hideifdefault").hide();
191 jQuery(".hideifdefault").show();
194 if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'mail\')
196 console.log("I choose php mail mode");
197 jQuery(".drag").hide();
198 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val(0);
199 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").prop("disabled", true);
200 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val(0);
201 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").prop("disabled", true);
202 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val(0);
203 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").prop("disabled", true);
204 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_EMAILING").val(0);
205 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_EMAILING").prop("disabled", true);
206 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN_EMAILING").prop("disabled", true);
207 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR_EMAILING").prop("disabled", true);
208 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY_EMAILING").prop("disabled", true);
209 jQuery(".smtp_method").hide();
210 jQuery(".dkim").hide();
211 jQuery(".smtp_auth_method").hide();
215 jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").hide();
216 jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").hide();
217 jQuery("#smtp_server_mess").show();
218 jQuery("#smtp_port_mess").show();
222 jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").prop("disabled", true);
223 jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").prop("disabled", true);
224 jQuery("#smtp_server_mess").hide();
225 jQuery("#smtp_port_mess").hide();
230 if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'smtps\')
232 console.log("I choose smtps mail mode");
233 jQuery(".drag").show();
234 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_TLS_EMAILING').
');
235 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").removeAttr("disabled");
236 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS_EMAILING').
');
237 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").removeAttr("disabled");
238 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING').
');
239 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").removeAttr("disabled");
240 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_EMAILING").val(0);
241 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_EMAILING").prop("disabled", true);
242 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN_EMAILING").prop("disabled", true);
243 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR_EMAILING").prop("disabled", true);
244 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY_EMAILING").prop("disabled", true);
245 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN_EMAILING").hide();
246 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR_EMAILING").hide();
247 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY_EMAILING").hide();
248 jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").removeAttr("disabled");
249 jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").removeAttr("disabled");
250 jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").show();
251 jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").show();
252 jQuery("#smtp_port_mess").hide();
253 jQuery("#smtp_server_mess").hide();
254 jQuery(".smtp_method").show();
255 jQuery(".dkim").hide();
256 jQuery(".smtp_auth_method").show();
258 if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'swiftmailer\')
260 console.log("I choose swiftmailer mail mode");
261 jQuery(".drag").show();
262 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_TLS_EMAILING').
');
263 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").removeAttr("disabled");
264 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS_EMAILING').
');
265 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").removeAttr("disabled");
266 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING').
');
267 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").removeAttr("disabled");
268 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_EMAILING").val(0);
269 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_EMAILING").prop("disabled", true);
270 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN_EMAILING").prop("disabled", true);
271 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR_EMAILING").prop("disabled", true);
272 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY_EMAILING").prop("disabled", true);
273 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN_EMAILING").hide();
274 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR_EMAILING").hide();
275 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY_EMAILING").hide();
276 jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").removeAttr("disabled");
277 jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").removeAttr("disabled");
278 jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").show();
279 jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").show();
280 jQuery("#smtp_server_mess").hide();
281 jQuery("#smtp_port_mess").hide();
282 jQuery(".smtp_method").show();
283 jQuery(".dkim").show();
284 jQuery(".smtp_auth_method").show();
287 function change_smtp_auth_method() {
288 console.log("Call smtp auth method");
289 if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'smtps\') {
290 if (jQuery("#radio_oauth").prop("checked")) {
291 jQuery(".smtp_pw").hide();
292 jQuery(".smtp_oauth_service").show();
294 jQuery(".smtp_pw").show();
295 jQuery(".smtp_oauth_service").hide();
297 } else if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'swiftmailer\') {
298 if (jQuery("#radio_oauth").prop("checked")) {
299 jQuery(".smtp_pw").hide();
300 jQuery(".smtp_oauth_service").show();
302 jQuery(".smtp_pw").show();
303 jQuery(".smtp_oauth_service").hide();
306 jQuery(".smtp_pw").hide();
307 jQuery(".smtp_oauth_service").hide();
311 change_smtp_auth_method();
314 jQuery("#MAIN_MAIL_SENDMODE_EMAILING").change(function() {
315 change_smtp_auth_method();
318 jQuery("#radio_pw, #radio_plain, #radio_oauth").change(function() {
319 change_smtp_auth_method();
321 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").change(function() {
322 if (jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val() == 1)
323 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val(0);
325 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val(0);
327 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").change(function() {
328 if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val() == 1)
329 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val(0);
331 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val(0);
334 print
'</script>'.
"\n";
337 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
338 print
'<input type="hidden" name="token" value="'.newToken().
'">';
339 print
'<input type="hidden" name="action" value="update">';
343 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
349 print
'<table class="noborder centpercent">';
350 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameters").
'</td><td></td></tr>';
354 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
357 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
358 print $form->selectarray(
'MAIN_MAIL_SENDMODE_EMAILING', $listofmethods, $conf->global->MAIN_MAIL_SENDMODE_EMAILING);
362 $text = $langs->trans(
"Undefined");
364 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
365 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
366 print
'<input type="hidden" name="MAIN_MAIL_SENDMODE_EMAILING" value="' .
getDolGlobalString(
'MAIN_MAIL_SENDMODE_EMAILING').
'">';
372 print
'<tr class="oddeven hideifdefault">';
373 if (!$conf->use_javascript_ajax && $linuxlike &&
getDolGlobalString(
'MAIN_MAIL_SENDMODE_EMAILING') ==
'mail') {
375 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
377 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
381 $mainserver = (
getDolGlobalString(
'MAIN_MAIL_SMTP_SERVER_EMAILING') ? $conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING :
'');
382 $smtpserver = ini_get(
'SMTP') ? ini_get(
'SMTP') : $langs->transnoentities(
"Undefined");
384 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
386 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER", $smtpserver);
390 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
391 print
'<input class="flat minwidth300" id="MAIN_MAIL_SMTP_SERVER_EMAILING" name="MAIN_MAIL_SMTP_SERVER_EMAILING" size="18" value="' . $mainserver .
'">';
392 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_EMAILING_sav" name="MAIN_MAIL_SMTP_SERVER_EMAILING_sav" value="' . $mainserver .
'">';
393 print
'<span id="smtp_server_mess" class="opacitymedium">' . $langs->trans(
"SeeLocalSendMailSetup") .
'</span>';
394 print
' <span class="opacitymedium smtp_method">' . $langs->trans(
"SeeLinkToOnlineDocumentation") .
'</span>';
396 $text = !empty($mainserver) ? $mainserver : $smtpserver;
397 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
398 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
399 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_EMAILING" name="MAIN_MAIL_SMTP_SERVER_EMAILING" value="' . $mainserver .
'">';
407 print
'<tr class="oddeven hideifdefault hideonmodemail"><td>';
408 if (!$conf->use_javascript_ajax && $linuxlike &&
getDolGlobalString(
'MAIN_MAIL_SENDMODE_EMAILING') ==
'mail') {
409 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
411 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
413 $mainport = (
getDolGlobalString(
'MAIN_MAIL_SMTP_PORT_EMAILING') ? $conf->global->MAIN_MAIL_SMTP_PORT_EMAILING :
'');
414 $smtpport = ini_get(
'smtp_port') ? ini_get(
'smtp_port') : $langs->transnoentities(
"Undefined");
416 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
418 print $langs->trans(
"MAIN_MAIL_SMTP_PORT", $smtpport);
422 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
423 print
'<input class="flat" id="MAIN_MAIL_SMTP_PORT_EMAILING" name="MAIN_MAIL_SMTP_PORT_EMAILING" size="3" value="' . $mainport .
'">';
424 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT_EMAILING_sav" name="MAIN_MAIL_SMTP_PORT_EMAILING_sav" value="' . $mainport .
'">';
425 print
'<span id="smtp_port_mess" class="opacitymedium">' . $langs->trans(
"SeeLocalSendMailSetup") .
'</span>';
427 $text = (!empty($mainport) ? $mainport : $smtpport);
428 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
429 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
430 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT_EMAILING" name="MAIN_MAIL_SMTP_PORT_EMAILING" value="' . $mainport .
'">';
436 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer')))) {
437 print
'<tr class="oddeven smtp_auth_method hideonmodemail hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE").
'</td><td>';
438 $vartosmtpstype =
'MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING';
439 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
441 print
'<input type="radio" id="radio_pw" name="'.$vartosmtpstype.
'" value="LOGIN"'.(
getDolGlobalString($vartosmtpstype,
'LOGIN') ==
'LOGIN' ?
' checked' :
'').
'> ';
442 print
'<label for="radio_pw" >'.$langs->trans(
"UseAUTHLOGIN").
'</label>';
444 print
'<input type="radio" id="radio_plain" name="'.$vartosmtpstype.
'" value="PLAIN"'.(
getDolGlobalString($vartosmtpstype,
'PLAIN') ==
'PLAIN' ?
' checked' :
'').
'> ';
445 print
'<label for="radio_plain" >'.$langs->trans(
"UseAUTHPLAIN").
'</label>';
447 print
'<input type="radio" id="radio_oauth" name="'.$vartosmtpstype.
'" value="XOAUTH2"'.(
getDolGlobalString($vartosmtpstype) ==
'XOAUTH2' ?
' checked' :
'').(isModEnabled(
'oauth') ?
'' :
' disabled').
'> ';
448 print
'<label for="radio_oauth" >'.$form->textwithpicto($langs->trans(
"UseOauth"), $langs->trans(
"OauthNotAvailableForAllAndHadToBeCreatedBefore")).
'</label>';
449 if (!isModEnabled(
'oauth')) {
450 print
' <a href="'.DOL_URL_ROOT.
'/admin/modules.php?search_keyword=oauth">'.$langs->trans(
"EnableModuleX",
"OAuth").
'</a>';
452 print
' <a href="'.DOL_URL_ROOT.
'/admin/oauth.php">'.$langs->trans(
"SetupModuleX",
" OAuth").
'</a>';
456 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
457 print $form->textwithpicto($langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE"), $htmltext, 1,
'superadmin');
458 print
'<input type="hidden" id="MAIN_MAIL_SMTPS_AUTH_TYPE" name="MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING" value="'.$value.
'">';
464 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer')))) {
465 $mainstmpid = (
getDolGlobalString(
'MAIN_MAIL_SMTPS_ID_EMAILING') ? $conf->global->MAIN_MAIL_SMTPS_ID_EMAILING :
'');
466 print
'<tr class="drag drop oddeven hideifdefault"><td>' . $langs->trans(
"MAIN_MAIL_SMTPS_ID") .
'</td><td>';
468 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
469 print
'<input class="flat" name="MAIN_MAIL_SMTPS_ID_EMAILING" size="32" value="' . $mainstmpid .
'">';
471 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
472 print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_ID_EMAILING, $htmltext, 1,
'superadmin');
473 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_ID_EMAILING" value="' . $mainstmpid .
'">';
479 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer')))) {
481 print
'<tr class="drag drop oddeven smtp_pw hideifdefault"><td>' . $langs->trans(
"MAIN_MAIL_SMTPS_PW") .
'</td><td>';
483 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
484 print
'<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW_EMAILING" size="32" value="' . $mainsmtppw .
'">';
486 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
487 print $form->textwithpicto(
getDolGlobalString(
'MAIN_MAIL_SMTPS_PW_EMAILING'), $htmltext, 1,
'superadmin');
488 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_PW_EMAILING" value="' . $mainsmtppw .
'">';
494 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer')))) {
495 print
'<tr class="oddeven smtp_oauth_service hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE").
'</td><td>';
498 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
500 print $form->selectarray(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING', $oauthservices, $conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING);
504 $text = $langs->trans(
"Undefined");
506 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
507 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
508 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING" value="' .
getDolGlobalString(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING').
'">';
515 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
516 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer')))) {
517 if (function_exists(
'openssl_open')) {
518 print $form->selectyesno(
'MAIN_MAIL_EMAIL_TLS_EMAILING', (
getDolGlobalString(
'MAIN_MAIL_EMAIL_TLS_EMAILING') ? $conf->global->MAIN_MAIL_EMAIL_TLS_EMAILING : 0), 1);
520 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
523 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
528 print
'<tr class="oddeven hideifdefault hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
529 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer')))) {
530 if (function_exists(
'openssl_open')) {
531 print $form->selectyesno(
'MAIN_MAIL_EMAIL_STARTTLS_EMAILING', (
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS_EMAILING') ? $conf->global->MAIN_MAIL_EMAIL_STARTTLS_EMAILING : 0), 1);
533 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
536 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
541 print
'<tr class="oddeven hideifdefault hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
542 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer')))) {
543 if (function_exists(
'openssl_open')) {
544 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);
546 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
549 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
557 print $form->buttonsSaveCancel();
563 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
566 print
'<div class="div-table-responsive-no-min">';
567 print
'<table class="noborder centpercent">';
568 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameters").
'</td><td></td></tr>';
571 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
574 $text = $langs->trans(
"Undefined").img_warning();
577 print
'<span class="opacitymedium">'.$text.
'</span>';
588 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>';
595 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>';
599 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE_EMAILING'), array(
'smtps',
'swiftmailer'))) {
602 if ($authtype ===
"LOGIN") {
603 $text = $langs->trans(
"UseAUTHLOGIN");
604 } elseif ($authtype ===
"PLAIN") {
605 $text = $langs->trans(
"UseAUTHPLAIN");
606 } elseif ($authtype ===
"XOAUTH2") {
607 $text = $langs->trans(
"UseOauth");
609 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE").
'</td><td>'.$text.
'</td></tr>';
613 if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer'))) {
614 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>'.
getDolGlobalString(
'MAIN_MAIL_SMTPS_ID_EMAILING').
'</td></tr>';
618 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") {
619 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_PW").
'</td><td>'.preg_replace(
'/./',
'*',
getDolGlobalString(
'MAIN_MAIL_SMTPS_PW_EMAILING')).
'</td></tr>';
626 $text = $langs->trans(
"Undefined").img_warning();
628 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE").
'</td><td>'.$text.
'</td></tr>';
635 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
636 if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer'))) {
637 if (function_exists(
'openssl_open')) {
640 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
643 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
652 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
653 if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer'))) {
654 if (function_exists(
'openssl_open')) {
657 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
660 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
669 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
670 if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer'))) {
671 if (function_exists(
'openssl_open')) {
674 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
677 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
700 print
info_admin($langs->trans(
"SendmailOptionMayHurtBuggedMTA"));
706 print
'<div class="tabsAction">';
708 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'">'.$langs->trans(
"Modify").
'</a>';
712 if (function_exists(
'fsockopen') && $port && $server) {
713 print
'<a class="butAction" href="' . $_SERVER[
"PHP_SELF"] .
'?action=testconnect">' . $langs->trans(
"DoTestServerAvailability") .
'</a>';
716 print
'<a class="butActionRefused classfortooltip" href="#" title="' . $langs->trans(
"FeatureNotAvailableOnLinux") .
'">' . $langs->trans(
"DoTestServerAvailability") .
'</a>';
719 print
'<a class="butAction" href="' . $_SERVER[
"PHP_SELF"] .
'?action=test&mode=init">' . $langs->trans(
"DoTestSend") .
'</a>';
721 if (isModEnabled(
'fckeditor')) {
722 print
'<a class="butAction" href="' . $_SERVER[
"PHP_SELF"] .
'?action=testhtml&mode=init">' . $langs->trans(
"DoTestSendHTML") .
'</a>';
729 if (
getDolGlobalString(
'MAIN_MAIL_SENDMODE_EMAILING') ==
'mail' && !in_array($action, array(
'testconnect',
'test',
'testhtml'))) {
730 $text = $langs->trans(
"WarningPHPMail", $listofmethods[
'mail'], $listofmethods[
'smtps']);
735 if ($action ==
'testconnect') {
736 print
'<div id="formmailaftertstconnect" name="formmailaftertstconnect"></div>';
739 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
740 $mail =
new CMailFile(
'',
'',
'',
'', array(), array(), array(),
'',
'', 0, 0,
'',
'',
'', $trackid, $sendcontext);
742 $result = $mail->check_server_port($server, $port);
744 print
'<div class="ok">'.$langs->trans(
"ServerAvailableOnIPOrPort", $server, $port).
'</div>';
746 $errormsg = $langs->trans(
"ServerNotAvailableOnIPOrPort", $server, $port);
749 $errormsg .=
' - '.$mail->error;
758 if ($action ==
'test' || $action ==
'testhtml') {
759 print
'<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
760 print
load_fiche_titre($action ==
'testhtml' ? $langs->trans(
"DoTestSendHTML") : $langs->trans(
"DoTestSend"));
765 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
767 $formmail->trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
768 $formmail->fromname = (GETPOSTISSET(
'fromname') ?
GETPOST(
'fromname',
'restricthtml') : $conf->global->MAIN_MAIL_EMAIL_FROM);
769 $formmail->frommail = (GETPOSTISSET(
'frommail') ?
GETPOST(
'frommail',
'restricthtml') : $conf->global->MAIN_MAIL_EMAIL_FROM);
770 $formmail->fromid = $user->id;
771 $formmail->fromalsorobot = 1;
772 $formmail->withfromreadonly = 0;
773 $formmail->withsubstit = 0;
774 $formmail->withfrom = 1;
775 $formmail->witherrorsto = 1;
776 $formmail->withto = (GETPOSTISSET(
'sendto') ?
GETPOST(
'sendto',
'restricthtml') : ($user->
email ? $user->
email : 1));
777 $formmail->withtocc = (GETPOSTISSET(
'sendtocc') ?
GETPOST(
'sendtocc',
'restricthtml') : 1);
778 $formmail->withtoccc = (GETPOSTISSET(
'sendtoccc') ?
GETPOST(
'sendtoccc',
'restricthtml') : 1);
779 $formmail->withtopic = (GETPOSTISSET(
'subject') ?
GETPOST(
'subject') : $langs->trans(
"Test"));
780 $formmail->withtopicreadonly = 0;
781 $formmail->withfile = 2;
782 $formmail->withbody = (GETPOSTISSET(
'message') ?
GETPOST(
'message',
'restricthtml') : ($action ==
'testhtml' ? $langs->transnoentities(
"PredefinedMailTestHtml") : $langs->transnoentities(
"PredefinedMailTest")));
783 $formmail->withbodyreadonly = 0;
784 $formmail->withcancel = 1;
785 $formmail->withdeliveryreceipt = 1;
786 $formmail->withfckeditor = ($action ==
'testhtml' ? 1 : 0);
787 $formmail->ckeditortoolbar =
'dolibarr_mailings';
789 $formmail->substit = $substitutionarrayfortest;
791 $formmail->param[
"action"] =
"send";
792 $formmail->param[
"models"] =
"body";
793 $formmail->param[
"mailid"] = 0;
794 $formmail->param[
"returnurl"] = $_SERVER[
"PHP_SELF"];
797 if (
GETPOST(
"mode",
"aZ09") ==
'init') {
798 $formmail->clear_attached_files();
801 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.
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.