05-28-2012, 02:06 PM
In fact, is very easy to add this function in the "add.php" file.
I do this with a function (SendMailMime) what is on my site:
on the file add.php after the line 643 where is written this:
i have put the function to send mails:
after just call the function with good parameters
It just a simply example for just one rewiever (it's my case), but i think it it possible de read the database and change the Mail_adress_of_a_rewiever for each rewiever.
And add for looking if "authorization" in parameters is False or True because a mail is send if the "authorization" is true or false
I think is not very hard to do but for today is all (i am tired, lol)
I hope that enjoy someone
and thanks foor the initial job.
Pat46fr
I do this with a function (SendMailMime) what is on my site:
on the file add.php after the line 643 where is written this:
Code:
// Call the plugin API
callPluginMethod('onAfterAdd',$fileId);
i have put the function to send mails:
Code:
// modified by pat46fr for sending a mail to a rewiever
function SendMailMIME($MailTo, $From, $Subject, $Body, $File="")
{
// generate a random string to be used as the boundary marker
$boundary="==Multipart_Boundary_x".md5(mt_rand())."x";
if ($File!="") {
// open the file for a binary read
$handle = fopen($File,'r');
// read the file content into a variable
$data = fread($handle,filesize($File));
// close the file
fclose($handle);
// now we encode it and split it into acceptable length lines
$data = chunk_split(base64_encode($data));
}
// now we'll build the message headers
$headers = "From: ".$From."\n"."MIME-Version: 1.0\n"."Content-Type: multipart/alternative;\n"." boundary=\"{$boundary}\"\n\n";
// next, we'll build the message body. note that we insert two dashes in front of the MIME boundary when we use it
$headers .= "--{$boundary}\n"."Content-Type: text/html; charset=iso-8859-1\n".$Body."\n\n";
if ($File!="") {
// now we'll insert a boundary to indicate we're starting the attachment we have to specify the content type, filename, and disposition as an attachment, then add the file content and set another boundary to indicate that the end of the file has been reached
$headers .= "--{".$boundary."}\n"."Content-Type: text/plain; charset=iso-8859-1\n"."name=\"{".$File."}\"\n"."Content-Transfer-Encoding: base64\n Content-Disposition: attachment; \n"."filename=\"{".$File."}\"\n\n".$data."\n\n--{".$boundary."}--\n";
}
// now we just send the message
$LF = "\n";
$headers = 'MIME-Version: 1.0'.$LF;
$headers .= 'Content-type: text/html; charset=iso-8859-1'.$LF;
$headers .= "From: ".$From.$LF;
return(@mail($MailTo, $Subject, $Body, $headers));
}
after just call the function with good parameters
Code:
// mail avis arrivee document
$bodyL = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"><html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"><title>ODM- Nouveau document</title><style type=\"text/css\"><!-- body,td,th { font-family: Verdana, Arial, Helvetica, sans-serif; font-size:12px;} body {background-color: #CCFFCC;}--></style></head>\n";
$bodyL.="<body>\n";
$bodyL.="Il y a un nouveau fichier a examiner";
$bodyL.="<p> qui vient d'être posté.</p>";
$bodyL.= "<a href='http://www.//[i]My_site.fr[/i]/odm/index.php'>Connectez vous pour le valider</a>";
SendMailMIME("[i]Mail_adress_of_a_rewiever[/i] ", "ODM", "Nouveau document", $bodyL,"");
//Fin modif pat46 *********************************************************
//the end of the initial code
header('Location: details.php?id=' . $fileId . '&last_message=' . $message);
}
}
........
It just a simply example for just one rewiever (it's my case), but i think it it possible de read the database and change the Mail_adress_of_a_rewiever for each rewiever.
And add for looking if "authorization" in parameters is False or True because a mail is send if the "authorization" is true or false

I hope that enjoy someone

Pat46fr