New: La page de config mail permet de tester l'envoi de mail avec ou sans attachement

This commit is contained in:
Laurent Destailleur 2007-07-08 17:51:56 +00:00
parent 425ed71447
commit 6eb1a23391

View File

@ -63,11 +63,20 @@ if (isset($_POST["action"]) && $_POST["action"] == 'update')
// Action envoi test mailing // Action envoi test mailing
if ($_POST["action"] == 'send' && ! $_POST["cancel"]) if ($_POST["action"] == 'send' && ! $_POST["cancel"])
{ {
$filepath = array();
$mimetype = array();
$filename = array();
$sendto = $_POST["sendto"]; $email_from = $conf->global->MAIN_MAIL_EMAIL_FROM;
$email_from= $conf->global->MAIN_MAIL_EMAIL_FROM; $sendto = $_POST["sendto"];
$subject="Dolibarr test"; $subject = $_POST['subject'];
$body="This is a test"; $body = $_POST['message'];
if ($_FILES['addedfile']['tmp_name'])
{
$filepath[0] = $_FILES['addedfile']['tmp_name'];
$mimetype[0] = $_FILES['addedfile']['type'];
$filename[0] = $_FILES['addedfile']['name'];
}
if (! $sendto) if (! $sendto)
{ {
@ -77,13 +86,9 @@ if ($_POST["action"] == 'send' && ! $_POST["cancel"])
{ {
require_once(DOL_DOCUMENT_ROOT."/lib/CMailFile.class.php"); require_once(DOL_DOCUMENT_ROOT."/lib/CMailFile.class.php");
$arr_file = array();
$arr_mime = array();
$arr_name = array();
// Le message est-il en html // Le message est-il en html
$msgishtml=0; // Non par defaut $msgishtml=0; // Non par defaut
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_MAILING) $msgishtml=1; //if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_MAILING) $msgishtml=1;
if (eregi('[ \t]*<html>',$message)) $msgishtml=1; if (eregi('[ \t]*<html>',$message)) $msgishtml=1;
// Pratique les substitutions sur le sujet et message // Pratique les substitutions sur le sujet et message
@ -91,7 +96,7 @@ if ($_POST["action"] == 'send' && ! $_POST["cancel"])
$body=make_substitutions($body,$substitutionarrayfortest); $body=make_substitutions($body,$substitutionarrayfortest);
$mailfile = new CMailFile($subject,$sendto,$email_from,$body, $mailfile = new CMailFile($subject,$sendto,$email_from,$body,
$arr_file,$arr_mime,$arr_name, $filepath,$mimetype,$filename,
'', '', 0, $msgishtml); '', '', 0, $msgishtml);
$result=$mailfile->sendfile(); $result=$mailfile->sendfile();
@ -203,11 +208,11 @@ else
$formmail->withfrom=1; $formmail->withfrom=1;
$formmail->withto=$user->email?$user->email:1; $formmail->withto=$user->email?$user->email:1;
$formmail->withcc=0; $formmail->withcc=0;
$formmail->withtopic=0; $formmail->withtopic=$langs->trans("Test");
$formmail->withtopicreadonly=1; $formmail->withtopicreadonly=0;
$formmail->withfile=0; $formmail->withfile=1;
$formmail->withbody=0; $formmail->withbody=$langs->trans("Test");
$formmail->withbodyreadonly=1; $formmail->withbodyreadonly=0;
$formmail->withcancel=1; $formmail->withcancel=1;
// Tableau des substitutions // Tableau des substitutions
$formmail->substit=$substitutionarrayfortest; $formmail->substit=$substitutionarrayfortest;