30require
'../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
45$langs->loadLangs(array(
"companies",
"products",
"admin",
"mails",
"other",
"errors"));
47$action =
GETPOST(
'action',
'aZ09');
48$cancel =
GETPOST(
'cancel',
'aZ09');
56$usersignature = $user->signature;
58if ($action ==
'test' || ($action ==
'send' && $trackid ==
'test')) {
62$substitutionarrayfortest = array(
63 '__USER_LOGIN__' => $user->login,
64 '__USER_EMAIL__' => $user->email,
65 '__USER_FIRSTNAME__' => $user->firstname,
66 '__USER_LASTNAME__' => $user->lastname,
67 '__USER_SIGNATURE__' => (($user->signature && !
getDolGlobalString(
'MAIN_MAIL_DO_NOT_USE_SIGN')) ? $usersignature :
''),
68 '__SENDEREMAIL_SIGNATURE__' => (($user->signature && !
getDolGlobalString(
'MAIN_MAIL_DO_NOT_USE_SIGN')) ? $usersignature :
''),
71 '__LASTNAME__' => $langs->trans(
"Lastname").
' ('.$langs->trans(
"Recipient").
')',
72 '__FIRSTNAME__' => $langs->trans(
"Firstname").
' ('.$langs->trans(
"Recipient").
')',
77 '__DOL_MAIN_URL_ROOT__' => DOL_MAIN_URL_ROOT,
78 '__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" />',
89if ($action ==
'update' && !$cancel) {
90 if (!
GETPOST(
"MAIN_MAIL_EMAIL_FROM",
'alphanohtml')) {
92 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"MAIN_MAIL_EMAIL_FROM")),
null,
'errors');
97 setEventMessages($langs->trans(
"ErrorBadEMail",
GETPOST(
"MAIN_MAIL_EMAIL_FROM",
'alphanohtml')),
null,
'errors');
111 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_PW")) {
114 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_AUTH_TYPE")) {
117 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE")) {
118 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_OAUTH_SERVICE",
GETPOST(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE",
'alphanohtml'),
'chaine', 0,
'',
$conf->entity);
126 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_DKIM_SELECTOR",
GETPOST(
"MAIN_MAIL_EMAIL_DKIM_SELECTOR",
'alphanohtml'),
'chaine', 0,
'',
$conf->entity);
127 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY",
GETPOST(
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY",
'alphanohtml'),
'chaine', 0,
'',
$conf->entity);
135 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?mainmenu=home&leftmenu=setup");
140if ($action ==
'disablephpmailwarning' && !$cancel) {
149$triggersendname =
'';
151$mode =
'emailfortest';
152$trackid = ($action ==
'send' ?
GETPOST(
'trackid',
'aZ09') : $action);
153$sendcontext =
'standard';
154include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
156if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'test') {
159if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'testhtml') {
160 $action =
'testhtml';
168$form =
new Form($db);
172if (preg_match(
'/^win/i', PHP_OS)) {
175if (preg_match(
'/^mac/i', PHP_OS)) {
180 $conf->global->MAIN_MAIL_SENDMODE =
'mail';
183$port =
getDolGlobalInt(
'MAIN_MAIL_SMTP_PORT', (
int) ini_get(
'smtp_port'));
189 $server =
'127.0.0.1';
193$wikihelp =
'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails';
194llxHeader(
'', $langs->trans(
"Setup"), $wikihelp,
'', 0, 0,
'',
'',
'',
'mod-admin page-mails');
201$listofmethods = array();
202$listofmethods[
'mail'] =
'PHP mail function';
203$listofmethods[
'smtps'] =
'SMTP/SMTPS socket library';
204if (version_compare(phpversion(),
'7.0',
'>=')) {
205 $listofmethods[
'swiftmailer'] =
'Swift Mailer socket library';
209$oauthservices = array();
211foreach (
$conf->global as $key => $val) {
212 if (!empty($val) && preg_match(
'/^OAUTH_.*_ID$/', $key)) {
213 $key = preg_replace(
'/^OAUTH_/',
'', $key);
214 $key = preg_replace(
'/_ID$/',
'', $key);
215 if (preg_match(
'/^.*-/', $key)) {
216 $name = preg_replace(
'/^.*-/',
'', $key);
218 $name = $langs->trans(
"NoName");
220 $provider = preg_replace(
'/-.*$/',
'', $key);
221 $provider = ucfirst(strtolower($provider));
223 $oauthservices[$key] = $name.
" (".$provider.
")";
227if ($action ==
'edit') {
228 if (
$conf->use_javascript_ajax) {
229 print
"\n".
'<script type="text/javascript">';
230 print
'jQuery(document).ready(function () {
231 function initfields()
233 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'mail\')
235 console.log("I choose php mail mode");
236 jQuery(".drag").hide();
237 jQuery("#MAIN_MAIL_EMAIL_TLS").val(0);
238 jQuery("#MAIN_MAIL_EMAIL_TLS").prop("disabled", true);
239 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(0);
240 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").prop("disabled", true);
241 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
242 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").prop("disabled", true);
243 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val(0);
244 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").prop("disabled", true);
245 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").prop("disabled", true);
246 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").prop("disabled", true);
247 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").prop("disabled", true);
248 jQuery(".smtp_method").hide();
249 jQuery(".dkim").hide();
250 jQuery(".smtp_auth_method").hide();
254 jQuery("#MAIN_MAIL_SMTP_SERVER").hide();
255 jQuery("#MAIN_MAIL_SMTP_PORT").hide();
256 jQuery("#smtp_server_mess").show();
257 jQuery("#smtp_port_mess").show();';
260 jQuery("#MAIN_MAIL_SMTP_SERVER").prop("disabled", true);
261 jQuery("#MAIN_MAIL_SMTP_PORT").prop("disabled", true);
262 jQuery("#smtp_server_mess").hide();
263 jQuery("#smtp_port_mess").hide();';
267 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'smtps\')
269 console.log("I choose smtps mode");
270 jQuery(".drag").show();
272 jQuery("#MAIN_MAIL_EMAIL_TLS").removeAttr("disabled");
273 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS').
');
274 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").removeAttr("disabled");
275 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED').
');
276 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").removeAttr("disabled");
277 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val(0);
278 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").prop("disabled", true);
279 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").prop("disabled", true);
280 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").prop("disabled", true);
281 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").prop("disabled", true);
282 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").hide();
283 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").hide();
284 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").hide();
285 jQuery("#MAIN_MAIL_SMTP_SERVER").removeAttr("disabled");
286 jQuery("#MAIN_MAIL_SMTP_PORT").removeAttr("disabled");
287 jQuery("#MAIN_MAIL_SMTP_SERVER").show();
288 jQuery("#MAIN_MAIL_SMTP_PORT").show();
289 jQuery("#smtp_server_mess").hide();
290 jQuery("#smtp_port_mess").hide();
291 jQuery(".smtp_method").show();
292 jQuery(".dkim").hide();
293 jQuery(".smtp_auth_method").show();
295 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\')
297 console.log("I choose swiftmailer mode");
298 jQuery(".drag").show();
300 jQuery("#MAIN_MAIL_EMAIL_TLS").removeAttr("disabled");
301 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS').
');
302 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").removeAttr("disabled");
303 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED').
');
304 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").removeAttr("disabled");
305 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_ENABLED').
');
306 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").removeAttr("disabled");
307 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").removeAttr("disabled");
308 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").removeAttr("disabled");
309 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").removeAttr("disabled");
310 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").show();
311 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").show();
312 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").show();
313 jQuery("#MAIN_MAIL_SMTP_SERVER").removeAttr("disabled");
314 jQuery("#MAIN_MAIL_SMTP_PORT").removeAttr("disabled");
315 jQuery("#MAIN_MAIL_SMTP_SERVER").show();
316 jQuery("#MAIN_MAIL_SMTP_PORT").show();
317 jQuery("#smtp_server_mess").hide();
318 jQuery("#smtp_port_mess").hide();
319 jQuery(".smtp_method").show();
320 jQuery(".dkim").show();
321 jQuery(".smtp_auth_method").show();
324 function change_smtp_auth_method() {
325 console.log("Call smtp auth method");
326 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'smtps\') {
327 if (jQuery("#radio_oauth").prop("checked")) {
328 jQuery(".smtp_pw").hide();
329 jQuery(".smtp_oauth_service").show();
331 jQuery(".smtp_pw").show();
332 jQuery(".smtp_oauth_service").hide();
334 } else if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\') {
335 if (jQuery("#radio_oauth").prop("checked")) {
336 jQuery(".smtp_pw").hide();
337 jQuery(".smtp_oauth_service").show();
339 jQuery(".smtp_pw").show();
340 jQuery(".smtp_oauth_service").hide();
343 jQuery(".smtp_pw").show();
344 jQuery(".smtp_oauth_service").hide();
348 change_smtp_auth_method();
349 jQuery("#MAIN_MAIL_SENDMODE").change(function() {
351 change_smtp_auth_method();
353 jQuery("#radio_pw, #radio_plain, #radio_oauth").change(function() {
354 change_smtp_auth_method();
356 jQuery("#MAIN_MAIL_EMAIL_TLS").change(function() {
357 if (jQuery("#MAIN_MAIL_EMAIL_TLS").val() == 1)
358 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(0);
360 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
362 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").change(function() {
363 if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val() == 1)
364 jQuery("#MAIN_MAIL_EMAIL_TLS").val(0);
366 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
369 print
'</script>'.
"\n";
372 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
373 print
'<input type="hidden" name="token" value="'.newToken().
'">';
374 print
'<input type="hidden" name="action" value="update">';
378 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
385 print
'<table class="noborder centpercent">';
386 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameters").
'</td><td></td></tr>';
389 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
392 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
393 print $form->selectarray(
'MAIN_MAIL_SENDMODE', $listofmethods,
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'));
397 $text = $langs->trans(
"Undefined");
399 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
400 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
401 print
'<input type="hidden" name="MAIN_MAIL_SENDMODE" value="'.getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail').
'">';
406 print
'<tr class="oddeven hideonmodemail">';
409 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
411 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
416 $smtpserver = ini_get(
'SMTP') ? ini_get(
'SMTP') : $langs->transnoentities(
"Undefined");
418 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
420 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER", $smtpserver);
424 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
425 print
'<input class="flat minwidth300" id="MAIN_MAIL_SMTP_SERVER" name="MAIN_MAIL_SMTP_SERVER" value="'.$mainserver.
'" autocomplete="off">';
426 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_sav" name="MAIN_MAIL_SMTP_SERVER_sav" value="'.$mainserver.
'">';
427 print
'<span id="smtp_server_mess" class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
428 print
' <span class="opacitymedium smtp_method">'.$langs->trans(
"SeeLinkToOnlineDocumentation").
'</span>';
430 $text = !empty($mainserver) ? $mainserver : $smtpserver;
431 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
432 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
433 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER" name="MAIN_MAIL_SMTP_SERVER" value="'.$mainserver.
'">';
440 print
'<tr class="oddeven hideonmodemail"><td>';
442 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
444 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
447 $smtpport = ini_get(
'smtp_port') ? ini_get(
'smtp_port') : $langs->transnoentities(
"Undefined");
449 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
451 print $langs->trans(
"MAIN_MAIL_SMTP_PORT", $smtpport);
455 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
456 print
'<input class="flat" id="MAIN_MAIL_SMTP_PORT" name="MAIN_MAIL_SMTP_PORT" size="3" value="'.$mainport.
'">';
457 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT_sav" name="MAIN_MAIL_SMTP_PORT_sav" value="'.$mainport.
'">';
458 print
'<span id="smtp_port_mess" class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
460 $text = (!empty($mainport) ? $mainport : $smtpport);
461 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
462 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
463 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT" name="MAIN_MAIL_SMTP_PORT" value="'.$mainport.
'">';
469 if (!empty(
$conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
470 print
'<tr class="oddeven smtp_auth_method"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE").
'</td><td>';
471 $vartosmtpstype =
'MAIN_MAIL_SMTPS_AUTH_TYPE';
472 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
474 print
'<input type="radio" id="radio_pw" name="'.$vartosmtpstype.
'" value="LOGIN"'.(
getDolGlobalString($vartosmtpstype,
'LOGIN') ==
'LOGIN' ?
' checked' :
'').
'> ';
475 print
'<label for="radio_pw" >'.$langs->trans(
"UseAUTHLOGIN").
'</label>';
477 print
'<input type="radio" id="radio_plain" name="'.$vartosmtpstype.
'" value="PLAIN"'.(
getDolGlobalString($vartosmtpstype,
'PLAIN') ==
'PLAIN' ?
' checked' :
'').
'> ';
478 print
'<label for="radio_plain" >'.$langs->trans(
"UseAUTHPLAIN").
'</label>';
480 print
'<input type="radio" id="radio_oauth" name="'.$vartosmtpstype.
'" value="XOAUTH2"'.(
getDolGlobalString($vartosmtpstype) ==
'XOAUTH2' ?
' checked' :
'').(isModEnabled(
'oauth') ?
'' :
' disabled').
'> ';
481 print
'<label for="radio_oauth" >'.$form->textwithpicto($langs->trans(
"UseOauth"), $langs->trans(
"OauthNotAvailableForAllAndHadToBeCreatedBefore")).
'</label>';
482 if (!isModEnabled(
'oauth')) {
483 print
' <a href="'.DOL_URL_ROOT.
'/admin/modules.php?search_keyword=oauth">'.$langs->trans(
"EnableModuleX",
"OAuth").
'</a>';
485 print
' <a href="'.DOL_URL_ROOT.
'/admin/oauth.php">'.$langs->trans(
"SetupModuleX",
" OAuth").
'</a>';
489 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
490 print $form->textwithpicto($langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE"), $htmltext, 1,
'superadmin');
491 print
'<input type="hidden" id="MAIN_MAIL_SMTPS_AUTH_TYPE" name="MAIN_MAIL_SMTPS_AUTH_TYPE" value="'.$value.
'">';
497 if (!empty(
$conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
499 print
'<tr class="drag drop oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>';
501 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
502 print
'<input class="flat" name="MAIN_MAIL_SMTPS_ID" size="32" value="'.$mainstmpid.
'">';
504 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
505 print $form->textwithpicto(
getDolGlobalString(
'MAIN_MAIL_SMTPS_ID'), $htmltext, 1,
'superadmin');
506 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_ID" value="'.$mainstmpid.
'">';
513 if (!empty(
$conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
515 print
'<tr class="drag drop oddeven smtp_pw"><td>';
516 print $form->textwithpicto($langs->trans(
"MAIN_MAIL_SMTPS_PW"), $langs->trans(
"WithGMailYouCanCreateADedicatedPassword"));
519 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
520 print
'<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW" size="32" value="' . htmlspecialchars($mainsmtppw, ENT_COMPAT,
'UTF-8') .
'" autocomplete="off">';
522 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
523 print $form->textwithpicto(
getDolGlobalString(
'MAIN_MAIL_SMTPS_PW'), $htmltext, 1,
'superadmin');
524 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_PW" value="' . htmlspecialchars($mainsmtppw, ENT_COMPAT,
'UTF-8') .
'">';
530 if (!empty(
$conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
531 print
'<tr class="oddeven smtp_oauth_service"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE").
'</td><td>';
534 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
535 print $form->selectarray(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE', $oauthservices,
getDolGlobalString(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE'));
539 $text = $langs->trans(
"Undefined");
541 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
542 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
543 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_OAUTH_SERVICE" value="' .
getDolGlobalString(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE').
'">';
549 print
'<tr class="oddeven hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
550 if (!empty(
$conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
551 if (function_exists(
'openssl_open')) {
554 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
557 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
562 print
'<tr class="oddeven hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
563 if (!empty(
$conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
564 if (function_exists(
'openssl_open')) {
567 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
570 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
575 print
'<tr class="oddeven hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
576 if (!empty(
$conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
577 if (function_exists(
'openssl_open')) {
578 print $form->selectyesno(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED', (
getDolGlobalString(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED') ?
getDolGlobalString(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED') : 0), 1);
580 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
583 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
588 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_ENABLED").
'</td><td>';
589 if (!empty(
$conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'swiftmailer')))) {
590 if (function_exists(
'openssl_open')) {
593 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
596 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
601 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_DOMAIN").
'</td>';
602 print
'<td><input class="flat" id="MAIN_MAIL_EMAIL_DKIM_DOMAIN" name="MAIN_MAIL_EMAIL_DKIM_DOMAIN" size="32" value="'.getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_DOMAIN');
603 print
'"></td></tr>';
606 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_SELECTOR").
'</td>';
607 print
'<td><input class="flat" id="MAIN_MAIL_EMAIL_DKIM_SELECTOR" name="MAIN_MAIL_EMAIL_DKIM_SELECTOR" size="32" value="'.getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_SELECTOR');
608 print
'"></td></tr>';
611 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").
'</td>';
612 print
'<td><textarea id="MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY" name="MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY" rows="15" cols="100">'.getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY').
'</textarea>';
621 print
'<table class="noborder centpercent">';
622 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"OtherOptions").
'</td><td></td></tr>';
625 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_FORCE_SENDTO").
'</td><td>';
626 print
'<input class="flat width300" name="MAIN_MAIL_FORCE_SENDTO" value="'.getDolGlobalString(
'MAIN_MAIL_FORCE_SENDTO').
'" />';
630 $help = $form->textwithpicto(
'', $langs->trans(
"EMailHelpMsgSPFDKIM"));
631 print
'<tr class="oddeven"><td class="fieldrequired">';
632 print $langs->trans(
"MAIN_MAIL_EMAIL_FROM", ini_get(
'sendmail_from') ? ini_get(
'sendmail_from') : $langs->transnoentities(
"Undefined"));
635 print
'<td><input class="flat minwidth300" name="MAIN_MAIL_EMAIL_FROM" value="'.getDolGlobalString(
'MAIN_MAIL_EMAIL_FROM');
636 print
'"></td></tr>';
640 $liste[
'user'] = $langs->trans(
'UserEmail');
641 $liste[
'company'] = $langs->trans(
'CompanyEmail').
' ('.(!
getDolGlobalString(
'MAIN_INFO_SOCIETE_MAIL') ? $langs->trans(
"NotDefined") :
getDolGlobalString(
'MAIN_INFO_SOCIETE_MAIL')).
')';
643 print
'<tr class="oddeven"><td>'.$langs->trans(
'MAIN_MAIL_DEFAULT_FROMTYPE').
'</td><td>';
644 print $form->selectarray(
'MAIN_MAIL_DEFAULT_FROMTYPE', $liste,
getDolGlobalString(
'MAIN_MAIL_DEFAULT_FROMTYPE'), 0);
648 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ERRORS_TO").
'</td>';
649 print
'<td><input class="flat width300" name="MAIN_MAIL_ERRORS_TO" value="'.getDolGlobalString(
'MAIN_MAIL_ERRORS_TO').
'">';
653 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_AUTOCOPY_TO").
'</td>';
654 print
'<td><input class="flat width300" name="MAIN_MAIL_AUTOCOPY_TO" value="'.getDolGlobalString(
'MAIN_MAIL_AUTOCOPY_TO').
'">';
658 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ENABLED_USER_DEST_SELECT").
'</td><td>';
659 print $form->selectyesno(
'MAIN_MAIL_ENABLED_USER_DEST_SELECT',
getDolGlobalString(
'MAIN_MAIL_ENABLED_USER_DEST_SELECT'), 1);
662 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_NO_WITH_TO_SELECTED").
'</td><td>';
663 print $form->selectyesno(
'MAIN_MAIL_NO_WITH_TO_SELECTED',
getDolGlobalString(
'MAIN_MAIL_NO_WITH_TO_SELECTED'), 1);
670 print $form->buttonsSaveCancel();
676 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
679 print $langs->trans(
"MAIN_DISABLE_ALL_MAILS");
680 if (!empty(
$conf->use_javascript_ajax)) {
681 print ajax_constantonoff(
'MAIN_DISABLE_ALL_MAILS', array(),
null, 0, 0, 1, 2, 0, 0,
'_red').
'</a>';
695 print
'<div class="div-table-responsive-no-min">';
696 print
'<table class="noborder centpercent">';
697 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameters").
'</td><td></td></tr>';
700 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
703 $text = $langs->trans(
"Undefined").img_warning();
709 $textwarning = $langs->trans(
"WarningPHPMail", $listofmethods[
'mail'], $listofmethods[
'smtps']).
'<br>'.$langs->trans(
"WarningPHPMailA").
'<br>'.$langs->trans(
"WarningPHPMailB").
'<br>'.$langs->trans(
"WarningPHPMailC").
'<br><br>'.$langs->trans(
"WarningPHPMailD");
710 print $form->textwithpicto(
'',
'<span class="small">'.$textwarning.
'</span>', 1,
'help',
'nomargintop');
719 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTP_SERVER", ini_get(
'SMTP') ? ini_get(
'SMTP') : $langs->transnoentities(
"Undefined")).
'</td><td>'.
getDolGlobalString(
'MAIN_MAIL_SMTP_SERVER').
'</td></tr>';
727 print
'<tr class="oddeven"><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').
'</td></tr>';
731 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
734 if ($authtype ===
"LOGIN") {
735 $text = $langs->trans(
"UseAUTHLOGIN");
736 } elseif ($authtype ===
"PLAIN") {
737 $text = $langs->trans(
"UseAUTHPLAIN");
738 } elseif ($authtype ===
"XOAUTH2") {
739 $text = $langs->trans(
"UseOauth");
741 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE").
'</td><td>'.$text.
'</td></tr>';
745 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
746 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>' .
getDolGlobalString(
'MAIN_MAIL_SMTPS_ID').
'</td></tr>';
751 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_PW").
'</td><td>'.preg_replace(
'/./',
'*',
getDolGlobalString(
'MAIN_MAIL_SMTPS_PW')).
'</td></tr>';
758 $text = $langs->trans(
"Undefined").img_warning();
760 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE").
'</td><td>'.$text.
'</td></tr>';
767 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
768 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
769 if (function_exists(
'openssl_open')) {
772 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
775 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
784 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
785 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
786 if (function_exists(
'openssl_open')) {
789 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
801 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
802 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
803 if (function_exists(
'openssl_open')) {
806 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
809 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
816 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_ENABLED").
'</td><td>';
817 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'swiftmailer'))) {
818 if (function_exists(
'openssl_open')) {
821 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
824 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
829 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_DOMAIN").
'</td>';
830 print
'<td>'.getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_DOMAIN');
834 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_SELECTOR").
'</td>';
835 print
'<td>'.getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_SELECTOR');
839 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").
'</td>';
840 print
'<td>'.getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY');
848 $messagetoshow = $langs->trans(
"WarningPHPMail", $listofmethods[
'mail'], $listofmethods[
'smtps']).
'<br>'.$langs->trans(
"WarningPHPMailA").
'<br>'.$langs->trans(
"WarningPHPMailB").
'<br>'.$langs->trans(
"WarningPHPMailC").
'<br><br>'.$langs->trans(
"WarningPHPMailD");
849 $messagetoshow .=
' '.$langs->trans(
"WarningPHPMailDbis",
'{s1}',
'{s2}');
850 $linktosetvar1 =
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=disablephpmailwarning&token='.
newToken().
'">';
851 $linktosetvar2 =
'</a>';
852 $messagetoshow = str_replace(
'{s1}', $linktosetvar1, $messagetoshow);
853 $messagetoshow = str_replace(
'{s2}', $linktosetvar2, $messagetoshow);
855 print
info_admin($messagetoshow, 0, 0,
'warning',
'nomargintop',
'',
'warning');
886 print
'<div class="div-table-responsive-no-min">';
887 print
'<table class="noborder centpercent">';
888 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"OtherOptions").
'</td><td></td></tr>';
892 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_FORCE_SENDTO").
'</td><td>'.
getDolGlobalString(
'MAIN_MAIL_FORCE_SENDTO');
897 print
img_warning($langs->trans(
"RecipientEmailsWillBeReplacedWithThisValue"));
904 $help = $form->textwithpicto(
'', $langs->trans(
"EMailHelpMsgSPFDKIM"));
905 print
'<tr class="oddeven"><td>';
906 print $langs->trans(
"MAIN_MAIL_EMAIL_FROM", ini_get(
'sendmail_from') ? ini_get(
'sendmail_from') : $langs->transnoentities(
"Undefined"));
919 $liste[
'user'] = $langs->trans(
'UserEmail');
920 $liste[
'company'] = $langs->trans(
'CompanyEmail').
' ('.
getDolGlobalString(
'MAIN_INFO_SOCIETE_MAIL', $langs->trans(
"NotDefined")).
')';
921 $sql =
'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.
'c_email_senderprofile';
922 $sql .=
' WHERE active = 1 AND (private = 0 OR private = '.((int) $user->id).
')';
923 $resql = $db->query($sql);
925 $num = $db->num_rows($resql);
928 $obj = $db->fetch_object($resql);
930 $liste[
'senderprofile_'.$obj->rowid] = $obj->label.
' <'.$obj->email.
'>';
938 print
'<tr class="oddeven"><td>'.$langs->trans(
'MAIN_MAIL_DEFAULT_FROMTYPE').
'</td>';
941 print $langs->trans(
'RobotEmail');
943 print $langs->trans(
'UserEmail');
949 include_once DOL_DOCUMENT_ROOT.
'/core/class/emailsenderprofile.class.php';
951 $emailsenderprofile->fetch($id);
952 print $emailsenderprofile->label.
' '.
dol_escape_htmltag(
'<'.$emailsenderprofile->email.
'>');
958 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ERRORS_TO").
'</td>';
959 print
'<td>'.(getDolGlobalString(
'MAIN_MAIL_ERRORS_TO'));
966 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_AUTOCOPY_TO").
'</td>';
971 foreach ($listofemail as $key => $val) {
978 print
img_warning($langs->trans(
"ErrorBadEMail", $val));
988 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ENABLED_USER_DEST_SELECT").
'</td><td>'.
yn(
getDolGlobalString(
'MAIN_MAIL_ENABLED_USER_DEST_SELECT')).
'</td></tr>';
990 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_NO_WITH_TO_SELECTED").
'</td><td>'.
yn(
getDolGlobalString(
'MAIN_MAIL_NO_WITH_TO_SELECTED')).
'</td></tr>';
1000 print
'<div class="tabsAction">';
1002 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'">'.$langs->trans(
"Modify").
'</a>';
1006 if (function_exists(
'fsockopen') ) {
1007 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testconnect&token='.
newToken().
'&date='.
dol_now().
'#formmailaftertstconnect">'.$langs->trans(
"DoTestServerAvailability").
'</a>';
1013 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=test&token='.
newToken().
'&mode=init#formmailbeforetitle">'.$langs->trans(
"DoTestSend").
'</a>';
1015 if (isModEnabled(
'fckeditor')) {
1016 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testhtml&token='.
newToken().
'&mode=init#formmailbeforetitle">'.$langs->trans(
"DoTestSendHTML").
'</a>';
1034 print
info_admin($langs->trans(
"SendmailOptionMayHurtBuggedMTA"));
1037 if (!in_array($action, array(
'testconnect',
'test',
'testhtml')) && !
getDolGlobalString(
'MAIN_DISABLE_ALL_MAILS')) {
1047 $text .= $langs->trans(
"WarningPHPMailSPFDMARC");
1052 $text .= $langs->trans(
"WarningPHPMailSPFDMARC");
1059 $text .= $langs->trans(
"WarningPHPMailSPF",
getDolGlobalString(
'MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD'));
1064 $text .= ($text ?
'<br><br>' :
'').$langs->trans(
"WarningPHPMail2",
getDolGlobalString(
'MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS'));
1069 $emailstotest = array();
1076 if (!empty($user->email)) {
1077 $emailstotest[$user->email] =
getDomainFromURL(preg_replace(
'/^.*@/',
'', $user->email), 1);
1079 $domainstotest = array();
1080 foreach ($emailstotest as $email => $domain) {
1081 if (empty($domainstotest[$domain])) {
1082 $domainstotest[$domain] = array($email => $email);
1084 $domainstotest[$domain][$email] = $email;
1089 foreach (array(
'SPF',
'DMARC') as $dnstype) {
1090 foreach ($domainstotest as $domaintotest => $listofemails) {
1093 if (!empty($domaintotest) && function_exists(
'dns_get_record') && !
getDolGlobalString(
'MAIN_DISABLE_DNS_GET_RECORD')) {
1094 $domain = $domaintotest;
1095 if ($dnstype ==
'DMARC') {
1096 $domain =
'_dmarc.'.$domain;
1098 $dnsinfo = dns_get_record($domain, DNS_TXT);
1100 if (!empty($dnsinfo) && is_array($dnsinfo)) {
1101 foreach ($dnsinfo as $info) {
1102 if (($dnstype ==
'SPF' && stripos($info[
'txt'],
'v=spf') !==
false)
1103 || ($dnstype ==
'DMARC' && stripos($info[
'txt'],
'v=dmarc') !==
false)) {
1105 $text .= ($text ?
'<br>' :
'').
'- '.$langs->trans(
"ActualMailDNSRecordFound",
'<b>'.$dnstype.
'</b>',
'<b>'.implode(
', ', $listofemails).
'</b>',
'<span class="opacitylow">'.$info[
'txt'].
'</span>');
1109 if (!$foundforemail) {
1110 $text .= ($text ?
'<br>' :
'').
'- '.$langs->trans(
"ActualMailDNSRecordFound",
'<b>'.$dnstype.
'</b>',
'<b>'.implode(
', ', $listofemails).
'</b>',
'<span class="opacitymedium">'.$langs->transnoentitiesnoconv(
"None").
'</span>');
1116 print
info_admin($langs->trans(
"SPFAndDMARCInformation").
' :<br>'.$text, 0, 0,
'1',
'');
1121 if ($action ==
'testconnect') {
1122 print
'<div id="formmailaftertstconnect" name="formmailaftertstconnect"></div>';
1125 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1126 $mail =
new CMailFile(
'',
'',
'',
'', array(), array(), array(),
'',
'', 0, 0,
'',
'',
'', $trackid, $sendcontext);
1127 $result = $mail->check_server_port($server, $port);
1129 print
'<div class="ok">'.$langs->trans(
"ServerAvailableOnIPOrPort", $server, $port).
'</div>';
1131 $errormsg = $langs->trans(
"ServerNotAvailableOnIPOrPort", $server, $port);
1134 $errormsg .=
' - '.$mail->error;
1143 if ($action ==
'test' || $action ==
'testhtml') {
1144 print
'<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
1145 print
load_fiche_titre($action ==
'testhtml' ? $langs->trans(
"DoTestSendHTML") : $langs->trans(
"DoTestSend"));
1150 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1152 $formmail->trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
1155 $formmail->fromid = $user->id;
1156 $formmail->fromalsorobot = 1;
1157 $formmail->fromtype = (GETPOSTISSET(
'fromtype') ?
GETPOST(
'fromtype',
'aZ09') :
getDolGlobalString(
'MAIN_MAIL_DEFAULT_FROMTYPE',
'user'));
1158 $formmail->withfromreadonly = 1;
1159 $formmail->withsubstit = 1;
1160 $formmail->withfrom = 1;
1161 $formmail->witherrorsto = 1;
1162 $formmail->withto = (GETPOSTISSET(
'sendto') ?
GETPOST(
'sendto',
'restricthtml') : ($user->
email ? $user->
email : 1));
1163 $formmail->withtocc = (GETPOSTISSET(
'sendtocc') ?
GETPOST(
'sendtocc',
'restricthtml') : 1);
1164 $formmail->withtoccc = (GETPOSTISSET(
'sendtoccc') ?
GETPOST(
'sendtoccc',
'restricthtml') : 1);
1165 $formmail->withtopic = (GETPOSTISSET(
'subject') ?
GETPOST(
'subject') : $langs->trans(
"Test"));
1166 $formmail->withtopicreadonly = 0;
1167 $formmail->withfile = 2;
1169 $formmail->withlayout =
'emailing';
1170 $formmail->withaiprompt = ($action ==
'testhtml' ?
'html' :
'text');
1172 $formmail->withbody = (GETPOSTISSET(
'message') ?
GETPOST(
'message',
'restricthtml') : ($action ==
'testhtml' ? $langs->transnoentities(
"PredefinedMailTestHtml") : $langs->transnoentities(
"PredefinedMailTest")));
1173 $formmail->withbodyreadonly = 0;
1174 $formmail->withcancel = 1;
1175 $formmail->withdeliveryreceipt = 1;
1176 $formmail->withfckeditor = ($action ==
'testhtml' ? 1 : 0);
1177 $formmail->ckeditortoolbar =
'dolibarr_mailings';
1179 $formmail->substit = $substitutionarrayfortest;
1181 $formmail->param[
"action"] =
"send";
1182 $formmail->param[
"models"] =
"body";
1183 $formmail->param[
"mailid"] = 0;
1184 $formmail->param[
"returnurl"] = $_SERVER[
"PHP_SELF"];
1187 if (
GETPOST(
"mode",
"aZ09") ==
'init') {
1188 $formmail->clear_attached_files();
1191 print $formmail->get_form(
'addfile',
'removefile');
1196 if (!empty($user->admin)) {
1198 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsWillHaveMessageID").
': ';
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,...
Class for EmailSenderProfile.
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.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
dol_now($mode='auto')
Return date for now.
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
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_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
getDomainFromURL($url, $mode=0)
Function get second level domain name.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.