26 require
'../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
31 $langs->loadLangs(array(
"companies",
"products",
"admin",
"mails",
"other",
"errors"));
33 $action =
GETPOST(
'action',
'aZ09');
34 $cancel =
GETPOST(
'cancel',
'aZ09');
40 $usersignature = $user->signature;
43 if ($action ==
'test' || $action ==
'send') {
47 $substitutionarrayfortest = array(
48 '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT,
49 '__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"/>' :
'',
50 '__USER_LOGIN__' => $user->login,
51 '__USER_EMAIL__' => $user->email,
52 '__USER_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature :
''),
53 '__ID__' =>
'RecipientIdRecord',
55 '__LASTNAME__' =>
'RecipientLastname',
56 '__FIRSTNAME__' =>
'RecipientFirstname',
57 '__ADDRESS__'=>
'RecipientAddress',
58 '__ZIP__'=>
'RecipientZip',
59 '__TOWN_'=>
'RecipientTown',
60 '__COUNTRY__'=>
'RecipientCountry'
70 if ($action ==
'update' && !$cancel) {
71 if (!$error && !
GETPOST(
"MAIN_MAIL_EMAIL_FROM",
'alphanohtml')) {
73 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"MAIN_MAIL_EMAIL_FROM")),
null,
'errors');
78 setEventMessages($langs->trans(
"ErrorBadEMail",
GETPOST(
"MAIN_MAIL_EMAIL_FROM",
'alphanohtml')),
null,
'errors');
83 dolibarr_set_const($db,
"MAIN_DISABLE_ALL_MAILS",
GETPOST(
"MAIN_DISABLE_ALL_MAILS",
'int'),
'chaine', 0,
'', $conf->entity);
84 dolibarr_set_const($db,
"MAIN_MAIL_FORCE_SENDTO",
GETPOST(
"MAIN_MAIL_FORCE_SENDTO",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
85 dolibarr_set_const($db,
"MAIN_MAIL_ENABLED_USER_DEST_SELECT",
GETPOST(
"MAIN_MAIL_ENABLED_USER_DEST_SELECT",
'int'),
'chaine', 0,
'', $conf->entity);
89 dolibarr_set_const($db,
"MAIN_MAIL_SMTP_SERVER",
GETPOST(
"MAIN_MAIL_SMTP_SERVER",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
90 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_ID",
GETPOST(
"MAIN_MAIL_SMTPS_ID",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
93 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_STARTTLS",
GETPOST(
"MAIN_MAIL_EMAIL_STARTTLS",
'int'),
'chaine', 0,
'', $conf->entity);
94 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED",
GETPOST(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED",
'int'),
'chaine', 0,
'', $conf->entity);
96 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_DKIM_ENABLED",
GETPOST(
"MAIN_MAIL_EMAIL_DKIM_ENABLED",
'int'),
'chaine', 0,
'', $conf->entity);
97 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_DKIM_DOMAIN",
GETPOST(
"MAIN_MAIL_EMAIL_DKIM_DOMAIN",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
98 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_DKIM_SELECTOR",
GETPOST(
"MAIN_MAIL_EMAIL_DKIM_SELECTOR",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
99 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY",
GETPOST(
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
101 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_FROM",
GETPOST(
"MAIN_MAIL_EMAIL_FROM",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
102 dolibarr_set_const($db,
"MAIN_MAIL_ERRORS_TO",
GETPOST(
"MAIN_MAIL_ERRORS_TO",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
103 dolibarr_set_const($db,
"MAIN_MAIL_AUTOCOPY_TO",
GETPOST(
"MAIN_MAIL_AUTOCOPY_TO",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
104 dolibarr_set_const($db,
'MAIN_MAIL_DEFAULT_FROMTYPE',
GETPOST(
'MAIN_MAIL_DEFAULT_FROMTYPE',
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
106 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?mainmenu=home&leftmenu=setup");
114 $actiontypecode =
'';
115 $triggersendname =
'';
117 $mode =
'emailfortest';
118 $trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
120 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
122 if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'test') {
125 if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'testhtml') {
126 $action =
'testhtml';
139 if (preg_match(
'/^win/i', PHP_OS)) {
142 if (preg_match(
'/^mac/i', PHP_OS)) {
146 if (empty($conf->global->MAIN_MAIL_SENDMODE)) {
147 $conf->global->MAIN_MAIL_SENDMODE =
'mail';
149 $port = !empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT : ini_get(
'smtp_port');
153 $server = !empty($conf->global->MAIN_MAIL_SMTP_SERVER) ? $conf->global->MAIN_MAIL_SMTP_SERVER : ini_get(
'SMTP');
155 $server =
'127.0.0.1';
159 $wikihelp =
'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails';
167 $listofmethods = array();
168 $listofmethods[
'mail'] =
'PHP mail function';
169 $listofmethods[
'smtps'] =
'SMTP/SMTPS socket library';
170 if (version_compare(phpversion(),
'7.0',
'>=')) {
171 $listofmethods[
'swiftmailer'] =
'Swift Mailer socket library';
175 if ($action ==
'edit') {
176 if ($conf->use_javascript_ajax) {
177 print
"\n".
'<script type="text/javascript">';
178 print
'jQuery(document).ready(function () {
179 function initfields()
181 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'mail\')
183 console.log("I choose php mail mode");
184 jQuery(".drag").hide();
185 jQuery("#MAIN_MAIL_EMAIL_TLS").val(0);
186 jQuery("#MAIN_MAIL_EMAIL_TLS").prop("disabled", true);
187 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(0);
188 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").prop("disabled", true);
189 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
190 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").prop("disabled", true);
191 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val(0);
192 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").prop("disabled", true);
193 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").prop("disabled", true);
194 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").prop("disabled", true);
195 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").prop("disabled", true);
196 jQuery(".smtp_method").hide();
197 jQuery(".dkim").hide();
201 jQuery("#MAIN_MAIL_SMTP_SERVER").hide();
202 jQuery("#MAIN_MAIL_SMTP_PORT").hide();
203 jQuery("#smtp_server_mess").show();
204 jQuery("#smtp_port_mess").show();';
207 jQuery("#MAIN_MAIL_SMTP_SERVER").prop("disabled", true);
208 jQuery("#MAIN_MAIL_SMTP_PORT").prop("disabled", true);
209 jQuery("#smtp_server_mess").hide();
210 jQuery("#smtp_port_mess").hide();';
214 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'smtps\')
216 console.log("I choose smtps mode");
217 jQuery(".drag").show();
218 jQuery("#MAIN_MAIL_EMAIL_TLS").val('.$conf->global->MAIN_MAIL_EMAIL_TLS.
');
219 jQuery("#MAIN_MAIL_EMAIL_TLS").removeAttr("disabled");
220 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val('.$conf->global->MAIN_MAIL_EMAIL_STARTTLS.
');
221 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").removeAttr("disabled");
222 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val('.$conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED.
');
223 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").removeAttr("disabled");
224 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val(0);
225 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").prop("disabled", true);
226 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").prop("disabled", true);
227 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").prop("disabled", true);
228 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").prop("disabled", true);
229 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").hide();
230 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").hide();
231 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").hide();
232 jQuery("#MAIN_MAIL_SMTP_SERVER").removeAttr("disabled");
233 jQuery("#MAIN_MAIL_SMTP_PORT").removeAttr("disabled");
234 jQuery("#MAIN_MAIL_SMTP_SERVER").show();
235 jQuery("#MAIN_MAIL_SMTP_PORT").show();
236 jQuery("#smtp_server_mess").hide();
237 jQuery("#smtp_port_mess").hide();
238 jQuery(".smtp_method").show();
239 jQuery(".dkim").hide();
241 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\')
243 console.log("I choose swiftmailer mode");
244 jQuery(".drag").show();
245 jQuery("#MAIN_MAIL_EMAIL_TLS").val('.$conf->global->MAIN_MAIL_EMAIL_TLS.
');
246 jQuery("#MAIN_MAIL_EMAIL_TLS").removeAttr("disabled");
247 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val('.$conf->global->MAIN_MAIL_EMAIL_STARTTLS.
');
248 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").removeAttr("disabled");
249 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val('.$conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED.
');
250 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").removeAttr("disabled");
251 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val('.$conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED.
');
252 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").removeAttr("disabled");
253 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").removeAttr("disabled");
254 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").removeAttr("disabled");
255 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").removeAttr("disabled");
256 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").show();
257 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").show();
258 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").show();
259 jQuery("#MAIN_MAIL_SMTP_SERVER").removeAttr("disabled");
260 jQuery("#MAIN_MAIL_SMTP_PORT").removeAttr("disabled");
261 jQuery("#MAIN_MAIL_SMTP_SERVER").show();
262 jQuery("#MAIN_MAIL_SMTP_PORT").show();
263 jQuery("#smtp_server_mess").hide();
264 jQuery("#smtp_port_mess").hide();
265 jQuery(".smtp_method").show();
266 jQuery(".dkim").show();
270 jQuery("#MAIN_MAIL_SENDMODE").change(function() {
273 jQuery("#MAIN_MAIL_EMAIL_TLS").change(function() {
274 if (jQuery("#MAIN_MAIL_EMAIL_TLS").val() == 1)
275 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(0);
277 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
279 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").change(function() {
280 if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val() == 1)
281 jQuery("#MAIN_MAIL_EMAIL_TLS").val(0);
283 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
286 print
'</script>'.
"\n";
289 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
290 print
'<input type="hidden" name="token" value="'.newToken().
'">';
291 print
'<input type="hidden" name="action" value="update">';
295 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
301 print
'<table class="noborder centpercent">';
302 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
305 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_DISABLE_ALL_MAILS").
'</td><td>';
310 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_FORCE_SENDTO").
'</td><td>';
311 print
'<input class="flat" name="MAIN_MAIL_FORCE_SENDTO" size="32" value="'.(!empty($conf->global->MAIN_MAIL_FORCE_SENDTO) ? $conf->global->MAIN_MAIL_FORCE_SENDTO :
'').
'" />';
318 print
'<table class="noborder centpercent">';
319 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td></td></tr>';
322 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
325 if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity)) {
326 print
$form->selectarray(
'MAIN_MAIL_SENDMODE', $listofmethods, $conf->global->MAIN_MAIL_SENDMODE);
328 $text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE];
330 $text = $langs->trans(
"Undefined");
332 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
333 print
$form->textwithpicto($text, $htmltext, 1,
'superadmin');
334 print
'<input type="hidden" name="MAIN_MAIL_SENDMODE" value="'.$conf->global->MAIN_MAIL_SENDMODE.
'">';
339 print
'<tr class="oddeven">';
340 if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE ==
'mail') {
342 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
344 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
348 $mainserver = (!empty($conf->global->MAIN_MAIL_SMTP_SERVER) ? $conf->global->MAIN_MAIL_SMTP_SERVER :
'');
349 $smtpserver = ini_get(
'SMTP') ?ini_get(
'SMTP') : $langs->transnoentities(
"Undefined");
351 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
353 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER", $smtpserver);
357 if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
358 print
'<input class="flat minwidth300" id="MAIN_MAIL_SMTP_SERVER" name="MAIN_MAIL_SMTP_SERVER" value="'.$mainserver.
'" autocomplete="off">';
359 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_sav" name="MAIN_MAIL_SMTP_SERVER_sav" value="'.$mainserver.
'">';
360 print
'<span id="smtp_server_mess" class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
361 print
' <span class="opacitymedium smtp_method">'.$langs->trans(
"SeeLinkToOnlineDocumentation").
'</span>';
363 $text = !empty($mainserver) ? $mainserver : $smtpserver;
364 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
365 print
$form->textwithpicto($text, $htmltext, 1,
'superadmin');
366 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER" name="MAIN_MAIL_SMTP_SERVER" value="'.$mainserver.
'">';
373 print
'<tr class="oddeven"><td>';
374 if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE ==
'mail') {
375 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
377 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
379 $mainport = (!empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT :
'');
380 $smtpport = ini_get(
'smtp_port') ?ini_get(
'smtp_port') : $langs->transnoentities(
"Undefined");
382 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
384 print $langs->trans(
"MAIN_MAIL_SMTP_PORT", $smtpport);
388 if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
389 print
'<input class="flat" id="MAIN_MAIL_SMTP_PORT" name="MAIN_MAIL_SMTP_PORT" size="3" value="'.$mainport.
'">';
390 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT_sav" name="MAIN_MAIL_SMTP_PORT_sav" value="'.$mainport.
'">';
391 print
'<span id="smtp_port_mess" class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
393 $text = (!empty($mainport) ? $mainport : $smtpport);
394 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
395 print
$form->textwithpicto($text, $htmltext, 1,
'superadmin');
396 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT" name="MAIN_MAIL_SMTP_PORT" value="'.$mainport.
'">';
402 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array(
'smtps',
'swiftmailer')))) {
403 $mainstmpid = (!empty($conf->global->MAIN_MAIL_SMTPS_ID) ? $conf->global->MAIN_MAIL_SMTPS_ID :
'');
404 print
'<tr class="drag drop oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>';
406 if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
407 print
'<input class="flat" name="MAIN_MAIL_SMTPS_ID" size="32" value="'.$mainstmpid.
'">';
409 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
410 print
$form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_ID, $htmltext, 1,
'superadmin');
411 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_ID" value="'.$mainstmpid.
'">';
417 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array(
'smtps',
'swiftmailer')))) {
418 $mainsmtppw = (!empty($conf->global->MAIN_MAIL_SMTPS_PW) ? $conf->global->MAIN_MAIL_SMTPS_PW :
'');
419 print
'<tr class="drag drop oddeven"><td>';
420 print
$form->textwithpicto($langs->trans(
"MAIN_MAIL_SMTPS_PW"), $langs->trans(
"WithGMailYouCanCreateADedicatedPassword"));
423 if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
424 print
'<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW" size="32" value="'.$mainsmtppw.
'" autocomplete="off">';
426 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
427 print
$form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_PW, $htmltext, 1,
'superadmin');
428 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_PW" value="'.$mainsmtppw.
'">';
434 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
435 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array(
'smtps',
'swiftmailer')))) {
436 if (function_exists(
'openssl_open')) {
437 print
$form->selectyesno(
'MAIN_MAIL_EMAIL_TLS', (!empty($conf->global->MAIN_MAIL_EMAIL_TLS) ? $conf->global->MAIN_MAIL_EMAIL_TLS : 0), 1);
439 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
442 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
447 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
448 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array(
'smtps',
'swiftmailer')))) {
449 if (function_exists(
'openssl_open')) {
450 print
$form->selectyesno(
'MAIN_MAIL_EMAIL_STARTTLS', (!empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS) ? $conf->global->MAIN_MAIL_EMAIL_STARTTLS : 0), 1);
452 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
455 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
460 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
461 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array(
'smtps',
'swiftmailer')))) {
462 if (function_exists(
'openssl_open')) {
463 print
$form->selectyesno(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED', (!empty($conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED) ? $conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED : 0), 1);
465 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
468 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
473 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_ENABLED").
'</td><td>';
474 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array(
'swiftmailer')))) {
475 if (function_exists(
'openssl_open')) {
476 print
$form->selectyesno(
'MAIN_MAIL_EMAIL_DKIM_ENABLED', (!empty($conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED) ? $conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED : 0), 1);
478 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
481 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
486 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_DOMAIN").
'</td>';
487 print
'<td><input class="flat" id="MAIN_MAIL_EMAIL_DKIM_DOMAIN" name="MAIN_MAIL_EMAIL_DKIM_DOMAIN" size="32" value="'.(!empty($conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN) ? $conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN :
'');
488 print
'"></td></tr>';
491 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_SELECTOR").
'</td>';
492 print
'<td><input class="flat" id="MAIN_MAIL_EMAIL_DKIM_SELECTOR" name="MAIN_MAIL_EMAIL_DKIM_SELECTOR" size="32" value="'.(!empty($conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR) ? $conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR :
'');
493 print
'"></td></tr>';
496 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").
'</td>';
497 print
'<td><textarea id="MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY" name="MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY" rows="15" cols="100">'.(!empty($conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY) ? $conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY :
'').
'</textarea>';
504 print
'<table class="noborder centpercent">';
505 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"OtherOptions").
'</td><td></td></tr>';
508 $help =
img_help(1, $langs->trans(
"EMailHelpMsgSPFDKIM"));
509 print
'<tr class="oddeven"><td class="fieldrequired">'.$langs->trans(
"MAIN_MAIL_EMAIL_FROM", ini_get(
'sendmail_from') ?ini_get(
'sendmail_from') : $langs->transnoentities(
"Undefined")).
' '.$help.
'</td>';
510 print
'<td><input class="flat minwidth200" name="MAIN_MAIL_EMAIL_FROM" value="'.(!empty($conf->global->MAIN_MAIL_EMAIL_FROM) ? $conf->global->MAIN_MAIL_EMAIL_FROM :
'');
511 print
'"></td></tr>';
515 $liste[
'user'] = $langs->trans(
'UserEmail');
516 $liste[
'company'] = $langs->trans(
'CompanyEmail').
' ('.(empty($conf->global->MAIN_INFO_SOCIETE_MAIL) ? $langs->trans(
"NotDefined") : $conf->global->MAIN_INFO_SOCIETE_MAIL).
')';
518 print
'<tr class="oddeven"><td>'.$langs->trans(
'MAIN_MAIL_DEFAULT_FROMTYPE').
'</td><td>';
519 print
$form->selectarray(
'MAIN_MAIL_DEFAULT_FROMTYPE', $liste,
getDolGlobalString(
'MAIN_MAIL_DEFAULT_FROMTYPE'), 0);
523 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ERRORS_TO").
'</td>';
524 print
'<td><input class="flat" name="MAIN_MAIL_ERRORS_TO" size="32" value="'.(!empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO :
'');
525 print
'"></td></tr>';
528 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_AUTOCOPY_TO").
'</td>';
529 print
'<td><input class="flat" name="MAIN_MAIL_AUTOCOPY_TO" size="32" value="'.(!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO) ? $conf->global->MAIN_MAIL_AUTOCOPY_TO :
'');
530 print
'"></td></tr>';
533 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ENABLED_USER_DEST_SELECT").
'</td><td>';
534 print
$form->selectyesno(
'MAIN_MAIL_ENABLED_USER_DEST_SELECT',
getDolGlobalString(
'MAIN_MAIL_ENABLED_USER_DEST_SELECT'), 1);
541 print
$form->buttonsSaveCancel();
547 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
550 print
'<div class="div-table-responsive-no-min">';
551 print
'<table class="noborder centpercent">';
552 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
555 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_DISABLE_ALL_MAILS").
'</td><td>'.
yn(!empty($conf->global->MAIN_DISABLE_ALL_MAILS));
556 if (!empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
561 if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
563 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_FORCE_SENDTO").
'</td><td>'.
getDolGlobalString(
'MAIN_MAIL_FORCE_SENDTO');
568 print
img_warning($langs->trans(
"RecipientEmailsWillBeReplacedWithThisValue"));
577 if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
580 print
'<div class="div-table-responsive-no-min">';
581 print
'<table class="noborder centpercent">';
582 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td></td></tr>';
585 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
586 $text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE];
588 $text = $langs->trans(
"Undefined").img_warning();
592 if ($conf->global->MAIN_MAIL_SENDMODE ==
'mail' && empty($conf->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) {
593 print
$form->textwithpicto(
'', $langs->trans(
"WarningPHPMail").
'<br>'.$langs->trans(
"WarningPHPMailA").
'<br>'.$langs->trans(
"WarningPHPMailB").
'<br>'.$langs->trans(
"WarningPHPMailC").
'<br><br>'.$langs->trans(
"WarningPHPMailD"), 1,
'warning');
599 if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE ==
'mail')) {
600 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").
'</td><td><span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span></td></tr>';
602 print
'<tr class="oddeven"><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) ? $conf->global->MAIN_MAIL_SMTP_SERVER :
'').
'</td></tr>';
606 if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE ==
'mail')) {
607 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").
'</td><td><span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span></td></tr>';
609 print
'<tr class="oddeven"><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) ? $conf->global->MAIN_MAIL_SMTP_PORT :
'').
'</td></tr>';
613 if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array(
'smtps',
'swiftmailer'))) {
614 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>'.$conf->global->MAIN_MAIL_SMTPS_ID.
'</td></tr>';
618 if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array(
'smtps',
'swiftmailer'))) {
619 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_PW").
'</td><td>'.preg_replace(
'/./',
'*', $conf->global->MAIN_MAIL_SMTPS_PW).
'</td></tr>';
623 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
624 if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array(
'smtps',
'swiftmailer'))) {
625 if (function_exists(
'openssl_open')) {
626 print
yn($conf->global->MAIN_MAIL_EMAIL_TLS);
628 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
631 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
636 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
637 if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array(
'smtps',
'swiftmailer'))) {
638 if (function_exists(
'openssl_open')) {
639 print
yn($conf->global->MAIN_MAIL_EMAIL_STARTTLS);
641 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
644 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
649 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
650 if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array(
'smtps',
'swiftmailer'))) {
651 if (function_exists(
'openssl_open')) {
652 print
yn($conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED);
654 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
657 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
662 if ($conf->global->MAIN_MAIL_SENDMODE ==
'swiftmailer') {
664 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_ENABLED").
'</td><td>';
665 if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array(
'swiftmailer'))) {
666 if (function_exists(
'openssl_open')) {
669 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
672 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
677 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_DOMAIN").
'</td>';
678 print
'<td>'.getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_DOMAIN');
682 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_SELECTOR").
'</td>';
683 print
'<td>'.getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_SELECTOR');
687 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").
'</td>';
688 print
'<td>'.getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY');
695 if ($conf->global->MAIN_MAIL_SENDMODE ==
'mail' && empty($conf->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) {
696 print
info_admin($langs->trans(
"WarningPHPMail").
'<br>'.$langs->trans(
"WarningPHPMailA").
'<br>'.$langs->trans(
"WarningPHPMailB").
'<br>'.$langs->trans(
"WarningPHPMailC").
'<br><br>'.$langs->trans(
"WarningPHPMailD"), 0, 0,
'warning');
701 print
'<div class="div-table-responsive-no-min">';
702 print
'<table class="noborder centpercent">';
703 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"OtherOptions").
'</td><td></td></tr>';
706 $help =
img_help(1, $langs->trans(
"EMailHelpMsgSPFDKIM"));
707 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_FROM", ini_get(
'sendmail_from') ?ini_get(
'sendmail_from') : $langs->transnoentities(
"Undefined")).
' '.$help.
'</td>';
708 print
'<td>'.$conf->global->MAIN_MAIL_EMAIL_FROM;
709 if (empty($conf->global->MAIN_MAIL_EMAIL_FROM)) {
711 } elseif (!
isValidEmail($conf->global->MAIN_MAIL_EMAIL_FROM)) {
718 $liste[
'user'] = $langs->trans(
'UserEmail');
719 $liste[
'company'] = $langs->trans(
'CompanyEmail').
' ('.(empty($conf->global->MAIN_INFO_SOCIETE_MAIL) ? $langs->trans(
"NotDefined") : $conf->global->MAIN_INFO_SOCIETE_MAIL).
')';
720 $sql =
'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.
'c_email_senderprofile';
721 $sql .=
' WHERE active = 1 AND (private = 0 OR private = '.((int) $user->id).
')';
722 $resql = $db->query($sql);
724 $num = $db->num_rows(
$resql);
727 $obj = $db->fetch_object(
$resql);
729 $liste[
'senderprofile_'.$obj->rowid] = $obj->label.
' <'.$obj->email.
'>';
737 print
'<tr class="oddeven"><td>'.$langs->trans(
'MAIN_MAIL_DEFAULT_FROMTYPE').
'</td>';
740 print $langs->trans(
'RobotEmail');
742 print $langs->trans(
'UserEmail');
746 $id = preg_replace(
'/senderprofile_/',
'',
getDolGlobalString(
'MAIN_MAIL_DEFAULT_FROMTYPE'));
748 include_once DOL_DOCUMENT_ROOT.
'/core/class/emailsenderprofile.class.php';
750 $emailsenderprofile->fetch($id);
751 print $emailsenderprofile->label.
' '.
dol_escape_htmltag(
'<'.$emailsenderprofile->email.
'>');
757 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ERRORS_TO").
'</td>';
758 print
'<td>'.(getDolGlobalString(
'MAIN_MAIL_ERRORS_TO'));
759 if (!empty($conf->global->MAIN_MAIL_ERRORS_TO) && !
isValidEmail($conf->global->MAIN_MAIL_ERRORS_TO)) {
765 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_AUTOCOPY_TO").
'</td>';
767 if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) {
768 $listofemail = explode(
',', $conf->global->MAIN_MAIL_AUTOCOPY_TO);
770 foreach ($listofemail as $key => $val) {
777 print
img_warning($langs->trans(
"ErrorBadEMail", $val));
787 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ENABLED_USER_DEST_SELECT").
'</td><td>'.
yn(!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)).
'</td></tr>';
797 print
'<div class="tabsAction">';
799 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'">'.$langs->trans(
"Modify").
'</a>';
801 if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
802 if ($conf->global->MAIN_MAIL_SENDMODE !=
'mail' || !$linuxlike) {
803 if (function_exists(
'fsockopen') && $port && $server) {
804 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testconnect&date='.
dol_now().
'#formmailaftertstconnect">'.$langs->trans(
"DoTestServerAvailability").
'</a>';
807 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"FeatureNotAvailableOnLinux").
'">'.$langs->trans(
"DoTestServerAvailability").
'</a>';
810 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=test&mode=init#formmailbeforetitle">'.$langs->trans(
"DoTestSend").
'</a>';
812 if (!empty($conf->fckeditor->enabled)) {
813 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testhtml&mode=init#formmailbeforetitle">'.$langs->trans(
"DoTestSendHTML").
'</a>';
820 if ($conf->global->MAIN_MAIL_SENDMODE ==
'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) {
832 print
info_admin($langs->trans(
"SendmailOptionMayHurtBuggedMTA"));
835 if (!in_array($action, array(
'testconnect',
'test',
'testhtml'))) {
837 if ($conf->global->MAIN_MAIL_SENDMODE ==
'mail') {
841 if ($conf->global->MAIN_MAIL_SENDMODE ==
'mail') {
842 if (!empty($conf->global->MAIN_EXTERNAL_MAIL_SPF_STRING_TO_ADD)) {
844 $text .= ($text ?
'<br><br>' :
'').
'<!-- MAIN_EXTERNAL_MAIL_SPF_STRING_TO_ADD -->'.$langs->trans(
"WarningPHPMailSPF", $conf->global->MAIN_EXTERNAL_MAIL_SPF_STRING_TO_ADD);
847 if (!empty($conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS)) {
849 $text .= ($text ?
'<br><br>' :
'').
'<!-- MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS -->'.$langs->trans(
"WarningPHPMailSPF", $conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS);
853 if (!empty($conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS)) {
856 $text .= ($text ?
'<br><br>' :
'').
'<!-- MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS -->'.$langs->trans(
"WarningPHPMail2", $conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS);
858 if (!empty($conf->global->MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD)) {
860 $text .= ($text ?
'<br><br>' :
'').
'<!-- MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD -->'.$langs->trans(
"WarningPHPMailSPF", $conf->global->MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD);
865 if (!empty($companyemail) && function_exists(
'dns_get_record')) {
866 $arrayofemailparts = explode(
'@', $companyemail);
867 if (count($arrayofemailparts) == 2) {
868 $domain = $arrayofemailparts[1];
869 $dnsinfo = dns_get_record($domain, DNS_TXT);
872 if (!empty($dnsinfo) && is_array($dnsinfo)) {
873 foreach ($dnsinfo as $info) {
874 if (strpos($info[
'txt'],
'v=spf') !==
false) {
875 $text .= ($text ?
'<br><br>' :
'').$langs->trans(
"ActualMailSPFRecordFound", $companyemail, $info[
'txt']);
885 if ($action ==
'testconnect') {
886 print
'<div id="formmailaftertstconnect" name="formmailaftertstconnect"></div>';
889 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
890 $mail =
new CMailFile(
'',
'',
'',
'', array(), array(), array(),
'',
'', 0,
'',
'',
'',
'', $trackid, $sendcontext);
891 $result = $mail->check_server_port($server, $port);
893 print
'<div class="ok">'.$langs->trans(
"ServerAvailableOnIPOrPort", $server, $port).
'</div>';
895 $errormsg = $langs->trans(
"ServerNotAvailableOnIPOrPort", $server, $port);
898 $errormsg .=
' - '.$mail->error;
907 if ($action ==
'test' || $action ==
'testhtml') {
908 print
'<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
909 print
load_fiche_titre($action ==
'testhtml' ? $langs->trans(
"DoTestSendHTML") : $langs->trans(
"DoTestSend"));
914 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
916 $formmail->trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
917 $formmail->fromname = (
GETPOSTISSET(
'fromname') ?
GETPOST(
'fromname') : $conf->global->MAIN_MAIL_EMAIL_FROM);
918 $formmail->frommail = (
GETPOSTISSET(
'frommail') ?
GETPOST(
'frommail') : $conf->global->MAIN_MAIL_EMAIL_FROM);
919 $formmail->fromid = $user->id;
920 $formmail->fromalsorobot = 1;
921 $formmail->fromtype = (
GETPOSTISSET(
'fromtype') ?
GETPOST(
'fromtype',
'aZ09') : (!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE) ? $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE :
'user'));
922 $formmail->withfromreadonly = 1;
923 $formmail->withsubstit = 1;
924 $formmail->withfrom = 1;
925 $formmail->witherrorsto = 1;
926 $formmail->withto = (
GETPOSTISSET(
'sendto') ?
GETPOST(
'sendto',
'restricthtml') : ($user->email ? $user->email : 1));
927 $formmail->withtocc = (
GETPOSTISSET(
'sendtocc') ?
GETPOST(
'sendtocc',
'restricthtml') : 1);
928 $formmail->withtoccc = (
GETPOSTISSET(
'sendtoccc') ?
GETPOST(
'sendtoccc',
'restricthtml') : 1);
929 $formmail->withtopic = (
GETPOSTISSET(
'subject') ?
GETPOST(
'subject') : $langs->trans(
"Test"));
930 $formmail->withtopicreadonly = 0;
931 $formmail->withfile = 2;
932 $formmail->withbody = (
GETPOSTISSET(
'message') ?
GETPOST(
'message',
'restricthtml') : ($action ==
'testhtml' ? $langs->transnoentities(
"PredefinedMailTestHtml") : $langs->transnoentities(
"PredefinedMailTest")));
933 $formmail->withbodyreadonly = 0;
934 $formmail->withcancel = 1;
935 $formmail->withdeliveryreceipt = 1;
936 $formmail->withfckeditor = ($action ==
'testhtml' ? 1 : 0);
937 $formmail->ckeditortoolbar =
'dolibarr_mailings';
939 $formmail->substit = $substitutionarrayfortest;
941 $formmail->param[
"action"] =
"send";
942 $formmail->param[
"models"] =
"body";
943 $formmail->param[
"mailid"] = 0;
944 $formmail->param[
"returnurl"] = $_SERVER[
"PHP_SELF"];
947 if (
GETPOST(
"mode",
"aZ09") ==
'init') {
948 $formmail->clear_attached_files();
951 print $formmail->get_form(
'addfile',
'removefile');
956 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsWillHaveMessageID").
': ';