diff --git a/lib/email/Email.inc b/lib/email/Email.inc index a84f18a..e9e5f8d 100644 --- a/lib/email/Email.inc +++ b/lib/email/Email.inc @@ -27,9 +27,9 @@ class Email { // create a new phpmailer object. $this->oMailer = new phpmailer(); $this->oMailer->isSMTP(); - $this->oMailer->Host = $default->system->get("emailServer"); - $this->oMailer->From = (strlen($sFromEmail) == 0) ? $default->system->get("emailFrom") : $sFromEmail; - $this->oMailer->FromName = (strlen($sFromName) == 0) ? $default->system->get("emailFromName") : $sFromName; + $this->oMailer->Host = $default->emailServer; + $this->oMailer->From = (strlen($sFromEmail) == 0) ? $default->emailFrom : $sFromEmail; + $this->oMailer->FromName = (strlen($sFromName) == 0) ? $default->emailFromName : $sFromName; $this->oMailer->WordWrap = 100; $this->oMailer->IsHTML(true); } @@ -37,11 +37,11 @@ class Email { /** * Sends an email to a specified recipient. * - * @param string the sender's email address (optional) - * @param string the sender's name (optional) * @param string the recipients email address * @param string the subject of the email * @param string the body of the email + * @param string the sender's email address (optional) + * @param string the sender's name (optional) * @return boolean true on email successfully sent, false otherwise and set $_SESSION["errorMessage"] */ function send($sToEmail, $sSubject, $sBody, $sFromEmail = "", $sFromName = "") { @@ -58,7 +58,19 @@ class Email { if ((strlen($sFromName) > 0) && ($sFromName != "")) { $this->oMailer->FromName = $sFromName; } - $this->oMailer->AddAddress($sToEmail); + + // if there are multiple addresses (; separated) + $aEmailAddresses = array(); + if (strpos($sToEmail, ";") > 0) { + // explode them + $aEmailAddresses = explode(";", $sToEmail); + for ($i=0; $ioMailer->AddAddress($aEmailAddresses[$i]); + $default->log->info("Email.inc adding " . $aEmailAddresses[$i]); + } + } else { + $this->oMailer->AddAddress($sToEmail); + } $this->oMailer->Subject = stripslashes($sSubject); $this->oMailer->Body = stripslashes($sBody); diff --git a/presentation/lookAndFeel/knowledgeTree/documentmanagement/emailBL.php b/presentation/lookAndFeel/knowledgeTree/documentmanagement/emailBL.php index 607e471..0048b1b 100644 --- a/presentation/lookAndFeel/knowledgeTree/documentmanagement/emailBL.php +++ b/presentation/lookAndFeel/knowledgeTree/documentmanagement/emailBL.php @@ -39,11 +39,13 @@ if (checkSession()) { } else { $sMessage = "Your colleague, " . $oUser->getName() . ", wishes you to view the document entitled '" . $oDocument->getName() . "'.\n Click on the hyperlink below to view it"; } - $sHyperLink = generateLink("/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewBL.php", "fDocumentID=$fDocumentID", $oDocument->getName()); + // add the link to the document to the mail + $sMessage .= ' ' . generateLink("/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewBL.php", "fDocumentID=$fDocumentID", $oDocument->getName()); //email the hyperlink - $oEmail = new Email(); - $oEmail->sendHyperlink($default->owl_email_from, "MRC DMS", $fToEmail, "Document link", $sMessage, $sHyperLink); + $oEmail = new Email(); + $oEmail->send($fToEmail, "Document link", $sMessage); + //go back to the document view page redirect("$default->rootUrl/control.php?action=viewDocument&fDocumentID=$fDocumentID"); } else { @@ -68,7 +70,7 @@ if (checkSession()) { $oPatternCustom = & new PatternCustom(); $oPatternCustom->setHtml(getDocumentEmailPage($oDocument)); - //$main->setErrorMessage("Please enter an email address of the form someone@somewhere.some postfix"); + $main->setErrorMessage("Please enter an email address of the form someone@somewhere.some postfix"); $main->setCentralPayload($oPatternCustom); $main->setFormAction($_SERVER["PHP_SELF"] . "?fDocumentID=$fDocumentID&fSendEmail=1"); $main->render(); @@ -88,12 +90,18 @@ if (checkSession()) { /** use regex to validate the format of the email address */ function validateEmailAddress($sEmailAddress) { - $bResult = ereg ("^[^@ ]+@[^@ ]+\.[^@ \.]+$", $sEmailAddress ); - if ($bResult) { - return TRUE; + $aEmailAddresses = array(); + if (strpos($sEmailAddress, ";")) { + $aEmailAddresses = explode(";", $sEmailAddress); } else { - return FALSE; + $aEmailAddresses[] = $sEmailAddress; } + $bToReturn = true; + for ($i=0; $i diff --git a/presentation/lookAndFeel/knowledgeTree/documentmanagement/emailUI.inc b/presentation/lookAndFeel/knowledgeTree/documentmanagement/emailUI.inc index 77d0cfe..cbb5e4c 100644 --- a/presentation/lookAndFeel/knowledgeTree/documentmanagement/emailUI.inc +++ b/presentation/lookAndFeel/knowledgeTree/documentmanagement/emailUI.inc @@ -38,10 +38,10 @@ function getDocumentEmailPage($oDocument) { global $default; $sToRender = getDocumentPath($oDocument) . "\n
\n"; $sToRender .= "\n"; - $sToRender .= "\n"; + $sToRender .= "\n"; $sToRender .= "\n"; $sToRender .= "\n"; - $sToRender .= "\n"; + $sToRender .= "\n"; $sToRender .= "\n"; $sToRender .= "\n"; $sToRender .= "
Email detailsEmail details
  
Recipient name:
Email address:
Email address:(separate multiple addresses with a semicolon)
  
graphicsUrl/widgets/email.gif\" />rootUrl/control.php?action=viewDocument&fDocumentID=" . $oDocument->getID() . "\">graphicsUrl/widgets/cancel.gif\" border=\"0\"/>
\n";