@ -46,9 +46,11 @@
import java.io.File ;
import java.io.IOException ;
import java.io.PrintWriter ;
import java.text.SimpleDateFormat ;
import java.util.Date ;
import de.anomic.data.messageBoard ;
import de.anomic.http.httpHeader ;
import de.anomic.plasma.plasmaSwitchboard ;
import de.anomic.server.serverFileUtils ;
@ -57,6 +59,7 @@ import de.anomic.server.serverSwitch;
import de.anomic.tools.crypt ;
import de.anomic.yacy.yacyCore ;
import de.anomic.yacy.yacySeed ;
import de.anomic.yacy.yacySeedDB ;
public class message {
@ -121,12 +124,15 @@ public class message {
prop . put ( "response" , "Thank you!" ) ;
// save message
switchboard . messageDB . write ( switchboard . messageDB . newEntry (
messageBoard . entry msgEntry = null ;
switchboard . messageDB . write ( msgEntry = switchboard . messageDB . newEntry (
"remote" ,
otherSeed . get ( "Name" , "anonymous" ) , otherSeed . hash ,
yacyCore . seedDB . mySeed . getName ( ) , yacyCore . seedDB . mySeed . hash ,
subject , message . getBytes ( ) ) ) ;
messageForwardingViaEmail ( env , msgEntry ) ;
// finally write notification
File notifierSource = new File ( switchboard . getRootPath ( ) , switchboard . getConfig ( "htRootPath" , "htroot" ) + "/env/grafics/notifierActive.gif" ) ;
File notifierDest = new File ( switchboard . getRootPath ( ) , switchboard . getConfig ( "htRootPath" , "htroot" ) + "/env/grafics/notifier.gif" ) ;
@ -141,6 +147,63 @@ public class message {
// return rewrite properties
return prop ;
}
/ *
* To : # [ to ] #
From : # [ from ] #
Subject : # [ subject ] #
Date : # [ date ] #
# [ message ] #
* /
private static void messageForwardingViaEmail ( serverSwitch env , messageBoard . entry msgEntry ) {
try {
if ( ! Boolean . valueOf ( env . getConfig ( "msgForwardingEnabled" , "false" ) ) . booleanValue ( ) ) return ;
// getting the sendmail configuration
String sendMailStr = env . getConfig ( "msgForwardingCmd" , "/usr/bin/sendmail -t" ) ;
String [ ] sendMail = sendMailStr . trim ( ) . split ( " " ) ;
// getting the recipient address
String sendMailTo = env . getConfig ( "msgForwardingTo" , "root@localhost" ) . trim ( ) ;
// building the message text
StringBuffer emailTxt = new StringBuffer ( ) ;
emailTxt . append ( "To: " )
. append ( sendMailTo )
. append ( "\nFrom: " )
. append ( "yacy@" )
. append ( yacyCore . seedDB . mySeed . getName ( ) )
. append ( "\nSubject: [YaCy] " )
. append ( msgEntry . subject ( ) )
. append ( "\nDate: " )
. append ( msgEntry . date ( ) )
. append ( "\n" )
. append ( "\nMessage from: " )
. append ( msgEntry . author ( ) )
. append ( "/" )
. append ( msgEntry . authorHash ( ) )
. append ( "\nMessage to: " )
. append ( msgEntry . recipient ( ) )
. append ( "/" )
. append ( msgEntry . recipientHash ( ) )
. append ( "\nCategory: " )
. append ( msgEntry . category ( ) )
. append ( "\n===================================================================\n" )
. append ( new String ( msgEntry . message ( ) ) ) ;
Process process = Runtime . getRuntime ( ) . exec ( sendMail ) ;
PrintWriter email = new PrintWriter ( process . getOutputStream ( ) ) ;
email . print ( emailTxt . toString ( ) ) ;
email . close ( ) ;
} catch ( Exception e ) {
yacyCore . log . logWarning ( "message: message forwarding via email failed. " , e ) ;
}
}
/ *
on 83
DEBUG : message post values = { youare = Ty2F86ekSWM5 , key = pPQSZaXD , iam = WSjicAx1hRio , process = permission }