[Commits] r625 - in trunk/webinterface: core mods/super/customers
new-commit at lists.openvcp.org
new-commit at lists.openvcp.org
Sun Jun 8 09:03:38 UTC 2008
Author: cryptronic
Date: 2008-06-08 09:03:38 +0000 (Sun, 08 Jun 2008)
New Revision: 625
Modified:
trunk/webinterface/core/Sendmail.class.php
trunk/webinterface/mods/super/customers/main.php
Log:
Fixed Bug while sending mails to customers
Fixes: #226
Modified: trunk/webinterface/core/Sendmail.class.php
===================================================================
--- trunk/webinterface/core/Sendmail.class.php 2008-04-30 19:17:28 UTC (rev 624)
+++ trunk/webinterface/core/Sendmail.class.php 2008-06-08 09:03:38 UTC (rev 625)
@@ -43,14 +43,16 @@
$this->DB =& OpenVCP::call('DB', 'getReference');
$this->AUTH =& OpenVCP::call('Auth', 'getReference');
$this->admin = AdminFactory::getInstance()->getUserByID($adminid);
- $content = $this->DB->select($this->DB->table_mail_templates, NULL, NULL, array('name' => $templateName, 'AND', 'adminid' => $this->admin->getId()));
- if(!is_array($content))
- {
- throw new exception (_("mail template does not exist")." \"".$templateName."\"");
- return;
+ if($templateName != "") {
+ $content = $this->DB->select($this->DB->table_mail_templates, NULL, NULL, array('name' => $templateName, 'AND', 'adminid' => $this->admin->getId()));
+ if(!is_array($content))
+ {
+ throw new exception (_("mail template does not exist")." \"".$templateName."\"");
+ return;
+ }
+ $this->mailContent = $content[0]['content'];
+ $this->mailSubject = $content[0]['subject'];
}
- $this->mailContent = $content[0]['content'];
- $this->mailSubject = $content[0]['subject'];
}
/**
@@ -69,6 +71,14 @@
return;
}
+ public function setSubject($subject) {
+ $this->mailSubject = $subject;
+ }
+
+ public function setContent($content) {
+ $this->mailContent = $content;
+ }
+
/**
* set's the mail receiver
*/
@@ -112,7 +122,6 @@
die($e->getMessage() . "\n");
}
-
$ret = $smtp->auth($this->admin->getSetting("smtp_user"), $this->admin->getSetting("smtp_password"), $this->admin->getSetting("smtp_authtype"));
@@ -129,14 +138,14 @@
{
throw new exception (_("Unable to add recipient")."<".$this->receiver.">: " . $res->getMessage() . "\n");
}
- echo "FROM: $from\n TO: ".$this->mailReceiver."\n";
- if (PEAR::isError($smtp->data("From: <".$from.">\r\n".
- "To: <".$this->mailReceiver.">\r\n".
- "Subject: ".$this->mailSubject."\r\n".
- "Date: ".date("r")."\r\n\r\n".
- $this->mailContent))) {
- die("Unable to send data\n");
- }
+
+ if (PEAR::isError($smtp->data("From: <".$from.">\r\n".
+ "To: <".$this->mailReceiver.">\r\n".
+ "Subject: ".$this->mailSubject."\r\n".
+ "Date: ".date("r")."\r\n\r\n".
+ $this->mailContent))) {
+ die("Unable to send data\n");
+ }
$smtp->disconnect();
}
Modified: trunk/webinterface/mods/super/customers/main.php
===================================================================
--- trunk/webinterface/mods/super/customers/main.php 2008-04-30 19:17:28 UTC (rev 624)
+++ trunk/webinterface/mods/super/customers/main.php 2008-06-08 09:03:38 UTC (rev 625)
@@ -79,9 +79,13 @@
}
else if($ok)
{
- $GUI->p(_("sending mail to")." ".$customer['email']);
- $admininfo = $DB->select($DB->table_admin, NULL, NULL, array('id' => $USERINFO['id']));
- sendMail($customer['email'], $_POST['subject'], createMailBody($_POST['mailbody'], $admininfo[0]), $_POST['signature']);
+ require_once("Sendmail.class.php");
+ $GUI->p(_("sending mail to")." ".$customer->getId());
+ $mail = new Sendmail("", $customer->getId());
+ $mail->setTo($customer->getEmailaddress());
+ $mail->setSubject($_POST['subject']);
+ $mail->setContent($_POST['mailbody']);
+ $mail->sendMail();
$div = $GUI->div(_("ok"), "#green");
}
else
More information about the Commits
mailing list