01-12-2010, 08:58 PM
jacques2009
2008-07-31 02:28:18 PDT
Hello,
quite newbie question .. I have been installing and setting ODM for a couple of days now, looks fine. However, i would have thought that an email could be sent to reviewers warning them that they have a document to review ...
Is there some parameter to enable somewhere ?
Thanks,
Jacques.
jonathanwminer
2008-07-31 10:15:44 PDT
Please add this as a feature request, under the "Tracker" menu.
Thanks
jacques2009
2008-08-01 05:21:55 PDT
Done !
Jacques.
tommcgee
2008-12-12 12:20:52 PST
Answering two questions at once, I needed to do this AND use an SMTP server. Here's what I did.
I installed the Pear Mail.php module and included this line near the top of the config_local.php file:
require_once '/opt/php/lib/php/Mail.php';
Then I put a custom function called "Smail" into the config_local.php file:
//A replacement mail function that allows use of the SMTP server on campus
function Smail($to,$subject,$body,$header) {
$host = "smtp.yourdomain.com"; //the name of your smtp server
$headers_raw = preg_split('/: */',$header); //since it's always "From: <!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e -->"
//$fh = fopen('/tmp/mailtest','w');
//fwrite($fh, $header . " " . $headers_raw[1]);
$headers = array( 'From' => $headers_raw[1], 'Subject' => $subject );
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => false));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
// echo("<p>" . $mail->getMessage() . "</p>");
//$fh = fopen('/tmp/mailtest','w');
fwrite($fh, $mail->getMessage());
} else {
// echo("<p>Message successfully sent!</p>");
}
}
Then everywhere in the package that the mail() command is invoked I just changed it to Smail().
Problem two, sending mail at time of posting. This goes into add.php right above the line that says
//back to main page
//send a message to reviewers -- $result_array[0] should be the user id (refer to user table)
//and $result_array[1] must be greater than 0
$mail_message = "A new document for your comment and approval has been posted at the Document Repository. \n\n";
$mail_message .= $_REQUEST['description'] . "\n\n";
$mail_message .= $_REQUEST['comment'] . "\n\n";
$mail_message .= "Please log in to <!-- m --><a class="postlink" href="http://my.domain.com/opendoc/">http://my.domain.com/opendoc/</a><!-- m --> to review '" . $_FILES['file']['name'] . "' and respond with your comments, approval or rejection.";
for($i = 0; $i<sizeof($result_array); $i++)
{
if ( $result_array[$i][1] > 0 ) {
$this_id = $result_array[$i][0];
$query = "SELECT Email FROM user WHERE id = '$this_id'";
$result = mysql_query($query, $GLOBALS['connection']) or die("Error in query: $query" .mysql_error());
list($mail_to) = mysql_fetch_row($result);
//echo ("$query : --$mail_to-- and $mail_message");
Smail($mail_to,'New Document For Your Review',$mail_message,"From: $message_sender" );
}
}
Notice I'm using that Smail() function; if you don't need SMTP rearrange it to give mail() what it expects.
jonathanwminer
2008-12-15 05:48:30 PST
Tom -
Excellent work; the Peal Mail function could be used even if the mailserver is "localhost" right?
- Jon
tommcgee
2008-12-15 06:21:24 PST
I would assume so, though I have no way to test it. Put in "localhost" instead of "smtp.mydomain.com" instead and see?
2008-07-31 02:28:18 PDT
Hello,
quite newbie question .. I have been installing and setting ODM for a couple of days now, looks fine. However, i would have thought that an email could be sent to reviewers warning them that they have a document to review ...
Is there some parameter to enable somewhere ?
Thanks,
Jacques.
jonathanwminer
2008-07-31 10:15:44 PDT
Please add this as a feature request, under the "Tracker" menu.
Thanks
jacques2009
2008-08-01 05:21:55 PDT
Done !
Jacques.
tommcgee
2008-12-12 12:20:52 PST
Answering two questions at once, I needed to do this AND use an SMTP server. Here's what I did.
I installed the Pear Mail.php module and included this line near the top of the config_local.php file:
require_once '/opt/php/lib/php/Mail.php';
Then I put a custom function called "Smail" into the config_local.php file:
//A replacement mail function that allows use of the SMTP server on campus
function Smail($to,$subject,$body,$header) {
$host = "smtp.yourdomain.com"; //the name of your smtp server
$headers_raw = preg_split('/: */',$header); //since it's always "From: <!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e -->"
//$fh = fopen('/tmp/mailtest','w');
//fwrite($fh, $header . " " . $headers_raw[1]);
$headers = array( 'From' => $headers_raw[1], 'Subject' => $subject );
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => false));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
// echo("<p>" . $mail->getMessage() . "</p>");
//$fh = fopen('/tmp/mailtest','w');
fwrite($fh, $mail->getMessage());
} else {
// echo("<p>Message successfully sent!</p>");
}
}
Then everywhere in the package that the mail() command is invoked I just changed it to Smail().
Problem two, sending mail at time of posting. This goes into add.php right above the line that says
//back to main page
//send a message to reviewers -- $result_array[0] should be the user id (refer to user table)
//and $result_array[1] must be greater than 0
$mail_message = "A new document for your comment and approval has been posted at the Document Repository. \n\n";
$mail_message .= $_REQUEST['description'] . "\n\n";
$mail_message .= $_REQUEST['comment'] . "\n\n";
$mail_message .= "Please log in to <!-- m --><a class="postlink" href="http://my.domain.com/opendoc/">http://my.domain.com/opendoc/</a><!-- m --> to review '" . $_FILES['file']['name'] . "' and respond with your comments, approval or rejection.";
for($i = 0; $i<sizeof($result_array); $i++)
{
if ( $result_array[$i][1] > 0 ) {
$this_id = $result_array[$i][0];
$query = "SELECT Email FROM user WHERE id = '$this_id'";
$result = mysql_query($query, $GLOBALS['connection']) or die("Error in query: $query" .mysql_error());
list($mail_to) = mysql_fetch_row($result);
//echo ("$query : --$mail_to-- and $mail_message");
Smail($mail_to,'New Document For Your Review',$mail_message,"From: $message_sender" );
}
}
Notice I'm using that Smail() function; if you don't need SMTP rearrange it to give mail() what it expects.
jonathanwminer
2008-12-15 05:48:30 PST
Tom -
Excellent work; the Peal Mail function could be used even if the mailserver is "localhost" right?
- Jon
tommcgee
2008-12-15 06:21:24 PST
I would assume so, though I have no way to test it. Put in "localhost" instead of "smtp.mydomain.com" instead and see?