6 public $expand = array();
23 $this->reset($action, $msg);
31 $this->expand = array(
32 'h' => php_uname(
'n') ,
40 $this->prefix =
false;
49 $expandNextChar =
false;
51 while ($p < mb_strlen($str)) {
52 $c = mb_substr($str, $p, 1);
53 if ($expandNextChar) {
56 } elseif (isset($this->expand[
$c])) {
57 $res.= $this->expand[
$c];
61 $expandNextChar =
false;
64 $expandNextChar =
true;
83 $from = $this->action->user->login .
'@' . php_uname(
'n');
91 $this->mailto = $mailto;
97 $this->subject = $this->expand(
$subject);
100 if (is_string($this->prefix) && strlen($this->prefix) > 0) {
101 $msg = $this->prefixize($this->prefix, $msg);
104 $htmlBody = sprintf(
'<pre>%s</pre>', htmlspecialchars($msg, ENT_QUOTES));
106 return $this->send($this->from, $this->mailto, $this->subject, $htmlBody, $msg);
127 public function send(
$from, $mailto,
$subject, $htmlBody, $altTextBody =
'', $attachments = array())
132 $recipients = array();
133 if (is_string($mailto)) {
134 foreach (preg_split(
'/\s*,\s*/', $mailto) as
$to) {
140 } elseif (is_array($mailto)) {
141 foreach ($mailto as
$to) {
145 foreach ($recipients as
$to) {
148 $message->setBody(
new \Dcp\Mail\Body($htmlBody,
'text/html'));
149 if (is_string($altTextBody) && strlen($altTextBody) > 0) {
150 $message->setAltBody(
new \Dcp\Mail\Body($altTextBody,
'text/plain'));
152 if (is_array($attachments)) {
153 foreach ($attachments as $att) {
154 if (!is_array($att) || !isset($att[
'file']) || !isset($att[
'name']) || !isset($att[
'mime'])) {
157 if (isset($att[
'cid'])) {
158 $message->addBodyRelatedAttachment(
new \Dcp\Mail\RelatedAttachment($att[
'file'], $att[
'name'], $att[
'mime']));
160 $message->addAttachment(
new \Dcp\Mail\Attachment($att[
'file'], $att[
'name'], $att[
'mime']));
165 error_log(__METHOD__ .
" " . sprintf(
"Error sending mail: %s",
$err));
174 if (!is_array($expand)) {
177 foreach ($expand as $k => $v) {
178 if (!is_string($v)) {
181 $this->expand[$k] = $v;
addExpand($expand=array())
getMailAddr($userid, $full=false)
static getParameterValue($application, $parameterName)
send($from, $mailto, $subject, $htmlBody, $altTextBody= '', $attachments=array())
reset(\Action &$action, $msg)
if($file) if($subject==""&&$file) if($subject=="") $err
__construct(\Action &$action, $msg)