02. juni 2005 - 11:55Der er
5 kommentarer og 1 løsning
Email funktion
Kan nogle hjælpe mig med at komme i gang med denne opgave:
Write a function for notifying a user by email when the change in a currency rate has exceeded the notification threshold. The function should take five arguments:
1. $email: The users email adress. 2. $name: The users name 3. $cid: The currency id for the currency 4. $currentrate: The current currency rate for the currency 5. $chng: The change in percentage between the last notified rate for the currency and the current rate for the currency. The value of $chng can be either positive or negative:
Here is an example email sent to a user of the Currency Alert system:
To: andelu$itu.dk Subject: uSD currency rate has increased From: CurrencyWatch Date: Tue, 04 Jan 2005 16:25:01 +0100
Dear Anders Lund
The USD currency rate is now 556.31 (relative to Danish Kroner). The USD currency rate has increased 11.26 percent since last notification.
Best regards Currencywatch.dk
Notice: Which of the terms "increased" or "decreased" is used should depend on whether $chng is positive or negative. It can be assumed that $chng is either positive or negative. The function should make use of the built-PHP function mail to send the email.
Er der nogle der har nogle løsningsforslag - jeg er en temmelig stor php-noob, så jeg er taknemmelig for al slags hjælp.
function ($email,$name,$cid$,$currentrate,$chng) { $TEXT="Din klient skal understøtte html"; $besked="din mail besked"; SendMail( "info@mail.dk","info mail", //sender $email, $name, //recipient "Valuta ændring", //subject $TEXT,$besked); }
function SendMail($From,$FromName,$To,$ToName,$Subject,$Text,$Html){ $OB="----=_OuterBoundary_000"; $IB="----=_InnerBoundery_001"; $Html=$Html?$Html:preg_replace("/\n/","{br}",$Text) or die("neither text nor html part present."); $Text=$Text?$Text:"Sorry, but you need an html mailer to read this mail."; $From or die("sender address missing"); $To or die("recipient address missing");
//Messages start with text/html alternatives in OB $Msg ="This is a multi-part message in MIME format.\n"; $Msg.="\n--".$OB."\n"; $Msg.="Content-Type: multipart/alternative;\n\tboundary=\"".$IB."\"\n\n";
// html section $Msg.="\n--".$IB."\n"; $Msg.="Content-Type: text/html;\n\tcharset=\"iso-8859-1\"\n"; $Msg.="Content-Transfer-Encoding: base64\n\n"; // html goes here $Msg.=chunk_split(base64_encode($Html))."\n\n";
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.