From d661e260855977d34672388cfa8766de55a73f93 Mon Sep 17 00:00:00 2001 From: Arun Persaud Date: Fri, 13 Feb 2009 23:40:26 -0800 Subject: CLEANUP: make emails more uniform provide a standard header and footer. Also prepare for emails to be send to the database for later delivery. --- include/functions.php | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) (limited to 'include/functions.php') diff --git a/include/functions.php b/include/functions.php index f982029..7141ec7 100644 --- a/include/functions.php +++ b/include/functions.php @@ -54,10 +54,49 @@ function config_check() return; } -function mymail($To,$Subject,$message,$header="") +function mymail($uid,$subject,$message) { + global $EmailName; + + /* check if user wants email right away or if we should save it in + * the database for later delivery + */ + if(0) + { + /* send to database (not yet implemented)*/ + } + else + { + /* send email right away */ + + /* add standard header and footer */ + $subject = "$EmailName".$subject; + + /* standard greeting */ + $header = "Hello ...\n\n"; + + /* and standard goodbye */ + $footer = "\n\nHave a nice day\n". + " your E-Doko service department\n\n". + "-- \n". + "You can change your mail delivery mode in the preference menu.\n". + 'web: http://doko.nubati.net '. + 'help: http://wiki.nubati.net/EmailDoko '. + 'bugs: http://wiki.nubati.net/EmailDokoIssues'; + + $To = DB_get_email('userid',$uid); + + sendmail($To,$subject,$header.$message.$footer); + } +} + +function sendmail($To,$Subject,$message) +{ + /* this function sends the mail or outputs to the screen in case of debugging */ global $debug,$EMAIL_REPLY; + $header = ""; + if(isset($EMAIL_REPLY)) $header .= "From: e-DoKo daemon <$EMAIL_REPLY>\r\n"; @@ -104,7 +143,7 @@ function myisset() function myerror($message) { echo "".htmlspecialchars($message)."\n"; - mymail($ADMIN_EMAIL,$EmailName." Error in Code",$message); + sendmail($ADMIN_EMAIL,$EmailName." Error in Code",$message); return; } -- cgit v1.2.3-18-g5258