27 require
'../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
29 require_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;
39 if ($action ==
'test' || $action ==
'send') {
43 $substitutionarrayfortest = array(
44 '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT,
45 '__ID__' =>
'RecipientIdRecord',
47 '__CHECK_READ__' => (!empty($object) && is_object($object) && is_object($object->thirdparty)) ?
'<img src="'.DOL_MAIN_URL_ROOT.
'/public/emailing/mailing-read.php?tag='.$object->thirdparty->tag.
'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).
'" width="1" height="1" style="width:1px;height:1px" border="0"/>' :
'',
48 '__USER_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature :
''),
49 '__SENDEREMAIL_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature :
''),
50 '__LOGIN__' => $user->login,
51 '__LASTNAME__' =>
'RecipientLastname',
52 '__FIRSTNAME__' =>
'RecipientFirstname',
53 '__ADDRESS__'=>
'RecipientAddress',
54 '__ZIP__'=>
'RecipientZip',
55 '__TOWN_'=>
'RecipientTown',
56 '__COUNTRY__'=>
'RecipientCountry'
70 if ($action ==
'update' && !$cancel) {
72 dolibarr_set_const($db,
"MAIN_MAIL_SENDMODE_EMAILING",
GETPOST(
"MAIN_MAIL_SENDMODE_EMAILING"),
'chaine', 0,
'', $conf->entity);
73 dolibarr_set_const($db,
"MAIN_MAIL_SMTP_PORT_EMAILING",
GETPOST(
"MAIN_MAIL_SMTP_PORT_EMAILING"),
'chaine', 0,
'', $conf->entity);
74 dolibarr_set_const($db,
"MAIN_MAIL_SMTP_SERVER_EMAILING",
GETPOST(
"MAIN_MAIL_SMTP_SERVER_EMAILING"),
'chaine', 0,
'', $conf->entity);
75 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_ID_EMAILING",
GETPOST(
"MAIN_MAIL_SMTPS_ID_EMAILING"),
'chaine', 0,
'', $conf->entity);
77 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_PW_EMAILING",
GETPOST(
"MAIN_MAIL_SMTPS_PW_EMAILING",
'none'),
'chaine', 0,
'', $conf->entity);
79 if (
GETPOSTISSET(
"MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING")) {
80 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING",
GETPOST(
"MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING",
'chaine'),
'chaine', 0,
'', $conf->entity);
82 if (
GETPOSTISSET(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING")) {
83 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING",
GETPOST(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING",
'chaine'),
'chaine', 0,
'', $conf->entity);
85 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_TLS_EMAILING",
GETPOST(
"MAIN_MAIL_EMAIL_TLS_EMAILING"),
'chaine', 0,
'', $conf->entity);
86 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_STARTTLS_EMAILING",
GETPOST(
"MAIN_MAIL_EMAIL_STARTTLS_EMAILING"),
'chaine', 0,
'', $conf->entity);
87 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);
89 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?mainmenu=home&leftmenu=setup");
97 $triggersendname =
'';
99 $mode =
'emailfortest';
100 $trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
101 $sendcontext =
'emailing';
102 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
104 if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'test') {
107 if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'testhtml') {
108 $action =
'testhtml';
121 if (preg_match(
'/^win/i', PHP_OS)) {
124 if (preg_match(
'/^mac/i', PHP_OS)) {
128 if (empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING)) {
129 $conf->global->MAIN_MAIL_SENDMODE_EMAILING =
'default';
131 $port = !empty($conf->global->MAIN_MAIL_SMTP_PORT_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_PORT_EMAILING : ini_get(
'smtp_port');
135 $server = !empty($conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING : ini_get(
'SMTP');
137 $server =
'127.0.0.1';
141 $wikihelp =
'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails';
149 $listofmethods = array();
150 $listofmethods[
'default'] = $langs->trans(
'DefaultOutgoingEmailSetup');
151 $listofmethods[
'mail'] =
'PHP mail function';
153 $listofmethods[
'smtps'] =
'SMTP/SMTPS socket library';
154 if (version_compare(phpversion(),
'7.0',
'>=')) {
155 $listofmethods[
'swiftmailer'] =
'Swift Mailer socket library';
159 $oauthservices = array();
161 foreach ($conf->global as $key => $val) {
162 if (!empty($val) && preg_match(
'/^OAUTH_.*_ID$/', $key)) {
163 $key = preg_replace(
'/^OAUTH_/',
'', $key);
164 $key = preg_replace(
'/_ID$/',
'', $key);
165 if (preg_match(
'/^.*-/', $key)) {
166 $name = preg_replace(
'/^.*-/',
'', $key);
168 $name = $langs->trans(
"NoName");
170 $provider = preg_replace(
'/-.*$/',
'', $key);
171 $provider = ucfirst(strtolower($provider));
173 $oauthservices[$key] = $name.
" (".$provider.
")";
177 if ($action ==
'edit') {
178 if ($conf->use_javascript_ajax) {
179 print
"\n".
'<script type="text/javascript">';
180 print
'jQuery(document).ready(function () {
181 function initfields()
183 if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'default\')
185 jQuery(".hideifdefault").hide();
189 jQuery(".hideifdefault").show();
192 if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'mail\')
194 jQuery(".drag").hide();
195 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val(0);
196 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").prop("disabled", true);
197 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val(0);
198 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").prop("disabled", true);
199 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val(0);
200 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").prop("disabled", true);
201 jQuery(".smtp_method").hide();
202 jQuery(".smtp_auth_method").hide();
206 jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").hide();
207 jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").hide();
208 jQuery("#smtp_server_mess").show();
209 jQuery("#smtp_port_mess").show();
213 jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").prop("disabled", true);
214 jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").prop("disabled", true);
215 jQuery("#smtp_server_mess").hide();
216 jQuery("#smtp_port_mess").hide();
221 if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'smtps\')
223 jQuery(".drag").show();
224 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val('.$conf->global->MAIN_MAIL_EMAIL_TLS_EMAILING.
');
225 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").removeAttr("disabled");
226 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val('.$conf->global->MAIN_MAIL_EMAIL_STARTTLS_EMAILING.
');
227 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").removeAttr("disabled");
228 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val('.$conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING.
');
229 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").removeAttr("disabled");
230 jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").removeAttr("disabled");
231 jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").removeAttr("disabled");
232 jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").show();
233 jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").show();
234 jQuery("#smtp_port_mess").hide();
235 jQuery("#smtp_server_mess").hide();
236 jQuery(".smtp_method").show();
237 jQuery(".smtp_auth_method").show();
239 if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'swiftmailer\')
241 jQuery(".drag").show();
242 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val('.$conf->global->MAIN_MAIL_EMAIL_TLS_EMAILING.
');
243 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").removeAttr("disabled");
244 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val('.$conf->global->MAIN_MAIL_EMAIL_STARTTLS_EMAILING.
');
245 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").removeAttr("disabled");
246 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val('.$conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING.
');
247 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").removeAttr("disabled");
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_server_mess").hide();
253 jQuery("#smtp_port_mess").hide();
254 jQuery(".smtp_method").show();
255 jQuery(".smtp_auth_method").show();
258 function change_smtp_auth_method() {
259 console.log(jQuery("#radio_pw").prop("checked"));
260 if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'smtps\' && jQuery("#radio_oauth").prop("checked")) {
261 jQuery(".smtp_oauth_service").show();
262 jQuery(".smtp_pw").hide();
263 } else if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'swiftmailer\' && jQuery("#radio_oauth").prop("checked")) {
264 jQuery(".smtp_oauth_service").show();
265 jQuery(".smtp_pw").hide();
266 } else if(jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'mail\' || jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'default\'){
267 jQuery(".smtp_oauth_service").hide();
268 jQuery(".smtp_pw").hide();
270 jQuery(".smtp_oauth_service").hide();
271 jQuery(".smtp_pw").show();
275 change_smtp_auth_method();
276 jQuery("#MAIN_MAIL_SENDMODE_EMAILING").change(function() {
278 change_smtp_auth_method();
280 jQuery("#radio_pw, #radio_oauth").change(function() {
281 change_smtp_auth_method();
283 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").change(function() {
284 if (jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val() == 1)
285 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val(0);
287 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val(0);
289 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").change(function() {
290 if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val() == 1)
291 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val(0);
293 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val(0);
296 print
'</script>'.
"\n";
299 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
300 print
'<input type="hidden" name="token" value="'.newToken().
'">';
301 print
'<input type="hidden" name="action" value="update">';
305 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
311 print
'<table class="noborder centpercent">';
312 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
316 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
319 if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity)) {
320 print
$form->selectarray(
'MAIN_MAIL_SENDMODE_EMAILING', $listofmethods, $conf->global->MAIN_MAIL_SENDMODE_EMAILING);
322 $text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE_EMAILING];
324 $text = $langs->trans(
"Undefined");
326 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
327 print
$form->textwithpicto($text, $htmltext, 1,
'superadmin');
328 print
'<input type="hidden" name="MAIN_MAIL_SENDMODE_EMAILING" value="'.$conf->global->MAIN_MAIL_SENDMODE_EMAILING.
'">';
334 print
'<tr class="oddeven hideifdefault">';
335 if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE_EMAILING ==
'mail') {
337 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
339 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
343 $mainserver = (!empty($conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING :
'');
344 $smtpserver = ini_get(
'SMTP') ?ini_get(
'SMTP') : $langs->transnoentities(
"Undefined");
346 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
348 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER", $smtpserver);
352 if (!
isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
353 print
'<input class="flat minwidth300" id="MAIN_MAIL_SMTP_SERVER_EMAILING" name="MAIN_MAIL_SMTP_SERVER_EMAILING" size="18" value="' . $mainserver .
'">';
354 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_EMAILING_sav" name="MAIN_MAIL_SMTP_SERVER_EMAILING_sav" value="' . $mainserver .
'">';
355 print
'<span id="smtp_server_mess" class="opacitymedium">' . $langs->trans(
"SeeLocalSendMailSetup") .
'</span>';
356 print
' <span class="opacitymedium smtp_method">' . $langs->trans(
"SeeLinkToOnlineDocumentation") .
'</span>';
358 $text = !empty($mainserver) ? $mainserver : $smtpserver;
359 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
360 print
$form->textwithpicto($text, $htmltext, 1,
'superadmin');
361 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_EMAILING" name="MAIN_MAIL_SMTP_SERVER_EMAILING" value="' . $mainserver .
'">';
369 print
'<tr class="oddeven hideifdefault"><td>';
370 if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE_EMAILING ==
'mail') {
371 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
373 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
375 $mainport = (!empty($conf->global->MAIN_MAIL_SMTP_PORT_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_PORT_EMAILING :
'');
376 $smtpport = ini_get(
'smtp_port') ?ini_get(
'smtp_port') : $langs->transnoentities(
"Undefined");
378 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
380 print $langs->trans(
"MAIN_MAIL_SMTP_PORT", $smtpport);
384 if (!
isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
385 print
'<input class="flat" id="MAIN_MAIL_SMTP_PORT_EMAILING" name="MAIN_MAIL_SMTP_PORT_EMAILING" size="3" value="' . $mainport .
'">';
386 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT_EMAILING_sav" name="MAIN_MAIL_SMTP_PORT_EMAILING_sav" value="' . $mainport .
'">';
387 print
'<span id="smtp_port_mess" class="opacitymedium">' . $langs->trans(
"SeeLocalSendMailSetup") .
'</span>';
389 $text = (!empty($mainport) ? $mainport : $smtpport);
390 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
391 print
$form->textwithpicto($text, $htmltext, 1,
'superadmin');
392 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT_EMAILING" name="MAIN_MAIL_SMTP_PORT_EMAILING" value="' . $mainport .
'">';
398 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer')))) {
399 print
'<tr class="oddeven smtp_auth_method hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE").
'</td><td>';
400 if (!
isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
402 print
'<input type="radio" id="radio_pw" name="MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING" value="LOGIN"'.(getDolGlobalString(
'MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING',
'LOGIN') ==
'LOGIN' ?
' checked' :
'').
'> ';
403 print
'<label for="radio_pw" >'.$langs->trans(
"UsePassword").
'</label>';
404 print
' ';
405 print
'<input type="radio" id="radio_oauth" name="MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING" value="XOAUTH2"'.(getDolGlobalString(
'MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING') ==
'XOAUTH2' ?
' checked' :
'').
'> ';
406 print
'<label for="radio_oauth" >'.$form->textwithpicto($langs->trans(
"UseOauth"), $langs->trans(
"OauthNotAvailableForAllAndHadToBeCreatedBefore")).
'</label>';
409 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
410 print
$form->textwithpicto($langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE"), $htmltext, 1,
'superadmin');
411 print
'<input type="hidden" id="MAIN_MAIL_SMTPS_AUTH_TYPE" name="MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING" value="'.$value.
'">';
417 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer')))) {
418 $mainstmpid = (!empty($conf->global->MAIN_MAIL_SMTPS_ID_EMAILING) ? $conf->global->MAIN_MAIL_SMTPS_ID_EMAILING :
'');
419 print
'<tr class="drag drop oddeven hideifdefault"><td>' . $langs->trans(
"MAIN_MAIL_SMTPS_ID") .
'</td><td>';
421 if (!
isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
422 print
'<input class="flat" name="MAIN_MAIL_SMTPS_ID_EMAILING" size="32" value="' . $mainstmpid .
'">';
424 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
425 print
$form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_ID_EMAILING, $htmltext, 1,
'superadmin');
426 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_ID_EMAILING" value="' . $mainstmpid .
'">';
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 $mainsmtppw = (!empty($conf->global->MAIN_MAIL_SMTPS_PW_EMAILING) ? $conf->global->MAIN_MAIL_SMTPS_PW_EMAILING :
'');
434 print
'<tr class="drag drop oddeven smtp_pw hideifdefault"><td>' . $langs->trans(
"MAIN_MAIL_SMTPS_PW") .
'</td><td>';
436 if (!
isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
437 print
'<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW_EMAILING" size="32" value="' . $mainsmtppw .
'">';
439 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
440 print
$form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_PW_EMAILING, $htmltext, 1,
'superadmin');
441 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_PW_EMAILING" value="' . $mainsmtppw .
'">';
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 print
'<tr class="oddeven smtp_oauth_service hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE").
'</td><td>';
451 if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity)) {
452 print
$form->selectarray(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING', $oauthservices, $conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING);
454 $text = $oauthservices[$conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING];
456 $text = $langs->trans(
"Undefined");
458 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
459 print
$form->textwithpicto($text, $htmltext, 1,
'superadmin');
460 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING" value="'.$conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING.
'">';
467 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
468 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer')))) {
469 if (function_exists(
'openssl_open')) {
470 print
$form->selectyesno(
'MAIN_MAIL_EMAIL_TLS_EMAILING', (!empty($conf->global->MAIN_MAIL_EMAIL_TLS_EMAILING) ? $conf->global->MAIN_MAIL_EMAIL_TLS_EMAILING : 0), 1);
472 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
475 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
480 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
481 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer')))) {
482 if (function_exists(
'openssl_open')) {
483 print
$form->selectyesno(
'MAIN_MAIL_EMAIL_STARTTLS_EMAILING', (!empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS_EMAILING) ? $conf->global->MAIN_MAIL_EMAIL_STARTTLS_EMAILING : 0), 1);
485 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
488 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
493 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
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 if (function_exists(
'openssl_open')) {
496 print
$form->selectyesno(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING', (!empty($conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING) ? $conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING : 0), 1);
498 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
501 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
509 print
$form->buttonsSaveCancel();
515 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
518 print
'<div class="div-table-responsive-no-min">';
519 print
'<table class="noborder centpercent">';
520 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
523 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
526 $text = $langs->trans(
"Undefined").img_warning();
529 print
'<span class="opacitymedium">'.$text.
'</span>';
535 if (!empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING !=
'default') {
537 if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING ==
'mail')) {
538 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").
'</td><td>'.$langs->trans(
"SeeLocalSendMailSetup").
'</td></tr>';
540 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTP_SERVER", ini_get(
'SMTP') ?ini_get(
'SMTP') : $langs->transnoentities(
"Undefined")).
'</td><td>'.(!empty($conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING :
'').
'</td></tr>';
544 if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING ==
'mail')) {
545 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").
'</td><td>'.$langs->trans(
"SeeLocalSendMailSetup").
'</td></tr>';
547 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>'.(!empty($conf->global->MAIN_MAIL_SMTP_PORT_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_PORT_EMAILING :
'').
'</td></tr>';
551 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE_EMAILING'), array(
'smtps',
'swiftmailer'))) {
553 $text = ($authtype ===
"LOGIN") ? $langs->trans(
"UsePassword") : ($authtype ===
"XOAUTH2" ? $langs->trans(
"UseOauth") :
'') ;
554 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE").
'</td><td>'.$text.
'</td></tr>';
558 if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer'))) {
559 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>'.
getDolGlobalString(
'MAIN_MAIL_SMTPS_ID_EMAILING').
'</td></tr>';
563 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") {
564 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_PW").
'</td><td>'.preg_replace(
'/./',
'*',
getDolGlobalString(
'MAIN_MAIL_SMTPS_PW_EMAILING')).
'</td></tr>';
569 $text = $oauthservices[$conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING];
571 $text = $langs->trans(
"Undefined").img_warning();
573 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING").
'</td><td>'.$text.
'</td></tr>';
578 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
579 if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer'))) {
580 if (function_exists(
'openssl_open')) {
581 print
yn($conf->global->MAIN_MAIL_EMAIL_TLS_EMAILING);
583 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
586 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
591 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
592 if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer'))) {
593 if (function_exists(
'openssl_open')) {
594 print
yn($conf->global->MAIN_MAIL_EMAIL_STARTTLS_EMAILING);
596 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
599 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
604 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
605 if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array(
'smtps',
'swiftmailer'))) {
606 if (function_exists(
'openssl_open')) {
609 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
612 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
623 if ($conf->global->MAIN_MAIL_SENDMODE_EMAILING ==
'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) {
634 print
info_admin($langs->trans(
"SendmailOptionMayHurtBuggedMTA"));
640 print
'<div class="tabsAction">';
642 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'">'.$langs->trans(
"Modify").
'</a>';
644 if (!empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING !=
'default') {
645 if ($conf->global->MAIN_MAIL_SENDMODE_EMAILING !=
'mail' || !$linuxlike) {
646 if (function_exists(
'fsockopen') && $port && $server) {
647 print
'<a class="butAction" href="' . $_SERVER[
"PHP_SELF"] .
'?action=testconnect">' . $langs->trans(
"DoTestServerAvailability") .
'</a>';
650 print
'<a class="butActionRefused classfortooltip" href="#" title="' . $langs->trans(
"FeatureNotAvailableOnLinux") .
'">' . $langs->trans(
"DoTestServerAvailability") .
'</a>';
653 print
'<a class="butAction" href="' . $_SERVER[
"PHP_SELF"] .
'?action=test&mode=init">' . $langs->trans(
"DoTestSend") .
'</a>';
656 print
'<a class="butAction" href="' . $_SERVER[
"PHP_SELF"] .
'?action=testhtml&mode=init">' . $langs->trans(
"DoTestSendHTML") .
'</a>';
663 if ($conf->global->MAIN_MAIL_SENDMODE_EMAILING ==
'mail' && !in_array($action, array(
'testconnect',
'test',
'testhtml'))) {
664 $text = $langs->trans(
"WarningPHPMail");
669 if ($action ==
'testconnect') {
670 print
'<div id="formmailaftertstconnect" name="formmailaftertstconnect"></div>';
673 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
674 $mail =
new CMailFile(
'',
'',
'',
'', array(), array(), array(),
'',
'', 0,
'',
'',
'',
'', $trackid, $sendcontext);
676 $result = $mail->check_server_port($server, $port);
678 print
'<div class="ok">'.$langs->trans(
"ServerAvailableOnIPOrPort", $server, $port).
'</div>';
680 $errormsg = $langs->trans(
"ServerNotAvailableOnIPOrPort", $server, $port);
683 $errormsg .=
' - '.$mail->error;
692 if ($action ==
'test' || $action ==
'testhtml') {
693 print
'<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
694 print
load_fiche_titre($action ==
'testhtml' ? $langs->trans(
"DoTestSendHTML") : $langs->trans(
"DoTestSend"));
699 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
701 $formmail->trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
702 $formmail->fromname = (
GETPOSTISSET(
'fromname') ?
GETPOST(
'fromname',
'restricthtml') : $conf->global->MAIN_MAIL_EMAIL_FROM);
703 $formmail->frommail = (
GETPOSTISSET(
'frommail') ?
GETPOST(
'frommail',
'restricthtml') : $conf->global->MAIN_MAIL_EMAIL_FROM);
704 $formmail->fromid = $user->id;
705 $formmail->fromalsorobot = 1;
706 $formmail->withfromreadonly = 0;
707 $formmail->withsubstit = 0;
708 $formmail->withfrom = 1;
709 $formmail->witherrorsto = 1;
710 $formmail->withto = (
GETPOSTISSET(
'sendto') ?
GETPOST(
'sendto',
'restricthtml') : ($user->email ? $user->email : 1));
711 $formmail->withtocc = (
GETPOSTISSET(
'sendtocc') ?
GETPOST(
'sendtocc',
'restricthtml') : 1);
712 $formmail->withtoccc = (
GETPOSTISSET(
'sendtoccc') ?
GETPOST(
'sendtoccc',
'restricthtml') : 1);
713 $formmail->withtopic = (
GETPOSTISSET(
'subject') ?
GETPOST(
'subject') : $langs->trans(
"Test"));
714 $formmail->withtopicreadonly = 0;
715 $formmail->withfile = 2;
716 $formmail->withbody = (
GETPOSTISSET(
'message') ?
GETPOST(
'message',
'restricthtml') : ($action ==
'testhtml' ? $langs->transnoentities(
"PredefinedMailTestHtml") : $langs->transnoentities(
"PredefinedMailTest")));
717 $formmail->withbodyreadonly = 0;
718 $formmail->withcancel = 1;
719 $formmail->withdeliveryreceipt = 1;
720 $formmail->withfckeditor = ($action ==
'testhtml' ? 1 : 0);
721 $formmail->ckeditortoolbar =
'dolibarr_mailings';
723 $formmail->substit = $substitutionarrayfortest;
725 $formmail->param[
"action"] =
"send";
726 $formmail->param[
"models"] =
"body";
727 $formmail->param[
"mailid"] = 0;
728 $formmail->param[
"returnurl"] = $_SERVER[
"PHP_SELF"];
731 if (
GETPOST(
"mode",
"aZ09") ==
'init') {
732 $formmail->clear_attached_files();
735 print $formmail->get_form(
'addfile',
'removefile');
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
email_admin_prepare_head()
Return array head with list of tabs to view object informations.
if($actionsave) if(!isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $wikihelp
View.
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,...
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
getDolGlobalInt($key, $default=0)
Return 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.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.