mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Fix setup of emails
This commit is contained in:
commit
0a319c6748
|
|
@ -669,6 +669,7 @@ if ($action == 'edit') {
|
|||
print '<span class="opacitymedium">'.$langs->trans("EMailsDesc")."</span><br>\n";
|
||||
print "<br><br>\n";
|
||||
|
||||
|
||||
if (!getDolGlobalString('MAIN_DISABLE_ALL_MAILS')) {
|
||||
print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
|
||||
print '<table class="noborder centpercent">';
|
||||
|
|
@ -833,135 +834,141 @@ if ($action == 'edit') {
|
|||
}
|
||||
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
|
||||
print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("ParametersForTestEnvironment").'</td><td>'.$langs->trans("Value").'</td></tr>';
|
||||
print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("ParametersForTestEnvironment").'</td><td>'.$langs->trans("Value").'</td></tr>';
|
||||
|
||||
// Disable
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_DISABLE_ALL_MAILS").'</td><td>'.yn(getDolGlobalString('MAIN_DISABLE_ALL_MAILS'));
|
||||
// Disable
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_DISABLE_ALL_MAILS").'</td><td>';
|
||||
if (!empty($conf->use_javascript_ajax)) {
|
||||
print ajax_constantonoff('MAIN_DISABLE_ALL_MAILS', array(), null, 0, 0, 1, 2, 0, 0, '_red').'</a>';
|
||||
} else {
|
||||
print yn(getDolGlobalString('MAIN_DISABLE_ALL_MAILS'));
|
||||
if (getDolGlobalString('MAIN_DISABLE_ALL_MAILS')) {
|
||||
print img_warning($langs->trans("Disabled"));
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
if (!getDolGlobalString('MAIN_DISABLE_ALL_MAILS')) {
|
||||
// Force e-mail recipient
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_FORCE_SENDTO").'</td><td>'.getDolGlobalString('MAIN_MAIL_FORCE_SENDTO');
|
||||
if (getDolGlobalString('MAIN_MAIL_FORCE_SENDTO')) {
|
||||
if (!isValidEmail(getDolGlobalString('MAIN_MAIL_FORCE_SENDTO'))) {
|
||||
print img_warning($langs->trans("ErrorBadEMail"));
|
||||
} else {
|
||||
print img_warning($langs->trans("RecipientEmailsWillBeReplacedWithThisValue"));
|
||||
}
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
|
||||
|
||||
print '<br>';
|
||||
|
||||
|
||||
print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("OtherOptions").'</td><td></td></tr>';
|
||||
|
||||
// From
|
||||
$help = $form->textwithpicto('', $langs->trans("EMailHelpMsgSPFDKIM"));
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from') ? ini_get('sendmail_from') : $langs->transnoentities("Undefined"));
|
||||
print ' '.$help;
|
||||
print '</td>';
|
||||
print '<td>' . getDolGlobalString('MAIN_MAIL_EMAIL_FROM');
|
||||
if (!getDolGlobalString('MAIN_MAIL_EMAIL_FROM')) {
|
||||
print img_warning($langs->trans("Mandatory"));
|
||||
} elseif (!isValidEmail($conf->global->MAIN_MAIL_EMAIL_FROM)) {
|
||||
print img_warning($langs->trans("ErrorBadEMail"));
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Default from type
|
||||
$liste = array();
|
||||
$liste['user'] = $langs->trans('UserEmail');
|
||||
$liste['company'] = $langs->trans('CompanyEmail').' ('.(!getDolGlobalString('MAIN_INFO_SOCIETE_MAIL') ? $langs->trans("NotDefined") : $conf->global->MAIN_INFO_SOCIETE_MAIL).')';
|
||||
$sql = 'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile';
|
||||
$sql .= ' WHERE active = 1 AND (private = 0 OR private = '.((int) $user->id).')';
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
if ($obj) {
|
||||
$liste['senderprofile_'.$obj->rowid] = $obj->label.' <'.$obj->email.'>';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
print '<tr class="oddeven"><td>'.$langs->trans('MAIN_MAIL_DEFAULT_FROMTYPE').'</td>';
|
||||
print '<td>';
|
||||
if (getDolGlobalString('MAIN_MAIL_DEFAULT_FROMTYPE') === 'robot') {
|
||||
print $langs->trans('RobotEmail');
|
||||
} elseif (getDolGlobalString('MAIN_MAIL_DEFAULT_FROMTYPE') === 'user') {
|
||||
print $langs->trans('UserEmail');
|
||||
} elseif (getDolGlobalString('MAIN_MAIL_DEFAULT_FROMTYPE') === 'company') {
|
||||
print $langs->trans('CompanyEmail').' '.dol_escape_htmltag('<'.$mysoc->email.'>');
|
||||
} else {
|
||||
$id = preg_replace('/senderprofile_/', '', getDolGlobalString('MAIN_MAIL_DEFAULT_FROMTYPE'));
|
||||
if ($id > 0) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/emailsenderprofile.class.php';
|
||||
$emailsenderprofile = new EmailSenderProfile($db);
|
||||
$emailsenderprofile->fetch($id);
|
||||
print $emailsenderprofile->label.' '.dol_escape_htmltag('<'.$emailsenderprofile->email.'>');
|
||||
}
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Errors To
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_ERRORS_TO").'</td>';
|
||||
print '<td>'.(getDolGlobalString('MAIN_MAIL_ERRORS_TO'));
|
||||
if (getDolGlobalString('MAIN_MAIL_ERRORS_TO') && !isValidEmail($conf->global->MAIN_MAIL_ERRORS_TO)) {
|
||||
print img_warning($langs->trans("ErrorBadEMail"));
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Autocopy to
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").'</td>';
|
||||
print '<td>';
|
||||
if (getDolGlobalString('MAIN_MAIL_AUTOCOPY_TO')) {
|
||||
$listofemail = explode(',', getDolGlobalString('MAIN_MAIL_AUTOCOPY_TO'));
|
||||
$i = 0;
|
||||
foreach ($listofemail as $key => $val) {
|
||||
if ($i) {
|
||||
print ', ';
|
||||
}
|
||||
$val = trim($val);
|
||||
print $val;
|
||||
if (!isValidEmail($val, 0, 1)) {
|
||||
print img_warning($langs->trans("ErrorBadEMail", $val));
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
print ' ';
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
//Add user to select destinaries list
|
||||
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>';
|
||||
//Disable autoselect to
|
||||
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>';
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
if (!getDolGlobalString('MAIN_DISABLE_ALL_MAILS')) {
|
||||
// Force e-mail recipient
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_FORCE_SENDTO").'</td><td>'.getDolGlobalString('MAIN_MAIL_FORCE_SENDTO');
|
||||
if (getDolGlobalString('MAIN_MAIL_FORCE_SENDTO')) {
|
||||
if (!isValidEmail(getDolGlobalString('MAIN_MAIL_FORCE_SENDTO'))) {
|
||||
print img_warning($langs->trans("ErrorBadEMail"));
|
||||
} else {
|
||||
print img_warning($langs->trans("RecipientEmailsWillBeReplacedWithThisValue"));
|
||||
}
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
|
||||
|
||||
print '<br>';
|
||||
|
||||
|
||||
print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("OtherOptions").'</td><td></td></tr>';
|
||||
|
||||
// From
|
||||
$help = $form->textwithpicto('', $langs->trans("EMailHelpMsgSPFDKIM"));
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from') ? ini_get('sendmail_from') : $langs->transnoentities("Undefined"));
|
||||
print ' '.$help;
|
||||
print '</td>';
|
||||
print '<td>' . getDolGlobalString('MAIN_MAIL_EMAIL_FROM');
|
||||
if (!getDolGlobalString('MAIN_MAIL_EMAIL_FROM')) {
|
||||
print img_warning($langs->trans("Mandatory"));
|
||||
} elseif (!isValidEmail($conf->global->MAIN_MAIL_EMAIL_FROM)) {
|
||||
print img_warning($langs->trans("ErrorBadEMail"));
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Default from type
|
||||
$liste = array();
|
||||
$liste['user'] = $langs->trans('UserEmail');
|
||||
$liste['company'] = $langs->trans('CompanyEmail').' ('.(!getDolGlobalString('MAIN_INFO_SOCIETE_MAIL') ? $langs->trans("NotDefined") : $conf->global->MAIN_INFO_SOCIETE_MAIL).')';
|
||||
$sql = 'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile';
|
||||
$sql .= ' WHERE active = 1 AND (private = 0 OR private = '.((int) $user->id).')';
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
if ($obj) {
|
||||
$liste['senderprofile_'.$obj->rowid] = $obj->label.' <'.$obj->email.'>';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
print '<tr class="oddeven"><td>'.$langs->trans('MAIN_MAIL_DEFAULT_FROMTYPE').'</td>';
|
||||
print '<td>';
|
||||
if (getDolGlobalString('MAIN_MAIL_DEFAULT_FROMTYPE') === 'robot') {
|
||||
print $langs->trans('RobotEmail');
|
||||
} elseif (getDolGlobalString('MAIN_MAIL_DEFAULT_FROMTYPE') === 'user') {
|
||||
print $langs->trans('UserEmail');
|
||||
} elseif (getDolGlobalString('MAIN_MAIL_DEFAULT_FROMTYPE') === 'company') {
|
||||
print $langs->trans('CompanyEmail').' '.dol_escape_htmltag('<'.$mysoc->email.'>');
|
||||
} else {
|
||||
$id = preg_replace('/senderprofile_/', '', getDolGlobalString('MAIN_MAIL_DEFAULT_FROMTYPE'));
|
||||
if ($id > 0) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/emailsenderprofile.class.php';
|
||||
$emailsenderprofile = new EmailSenderProfile($db);
|
||||
$emailsenderprofile->fetch($id);
|
||||
print $emailsenderprofile->label.' '.dol_escape_htmltag('<'.$emailsenderprofile->email.'>');
|
||||
}
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Errors To
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_ERRORS_TO").'</td>';
|
||||
print '<td>'.(getDolGlobalString('MAIN_MAIL_ERRORS_TO'));
|
||||
if (getDolGlobalString('MAIN_MAIL_ERRORS_TO') && !isValidEmail($conf->global->MAIN_MAIL_ERRORS_TO)) {
|
||||
print img_warning($langs->trans("ErrorBadEMail"));
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Autocopy to
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").'</td>';
|
||||
print '<td>';
|
||||
if (getDolGlobalString('MAIN_MAIL_AUTOCOPY_TO')) {
|
||||
$listofemail = explode(',', getDolGlobalString('MAIN_MAIL_AUTOCOPY_TO'));
|
||||
$i = 0;
|
||||
foreach ($listofemail as $key => $val) {
|
||||
if ($i) {
|
||||
print ', ';
|
||||
}
|
||||
$val = trim($val);
|
||||
print $val;
|
||||
if (!isValidEmail($val, 0, 1)) {
|
||||
print img_warning($langs->trans("ErrorBadEMail", $val));
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
print ' ';
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
//Add user to select destinaries list
|
||||
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>';
|
||||
//Disable autoselect to
|
||||
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>';
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
|
||||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user