Ticket #530: jmailer.3.diff
| File jmailer.3.diff, 3.5 kB (added by Lipki, 4 months ago) |
|---|
-
jMailer.class.php
old new 86 86 public $Body = ""; 87 87 88 88 /** 89 * Use tpl for sets the Body of the message. This can be either an HTML or text body. 90 * If HTML then run IsHTML(true). 91 * @var string 92 */ 93 public $bodyTpl; 94 95 /** 89 96 * Sets the text-only body of the message. This automatically sets the 90 97 * email to multipart/alternative. This body can be read by mail 91 98 * clients that do not have HTML email capability such as mutt. Clients … … 345 352 $this->ReplyTo[$cur][0] = trim($address); 346 353 $this->ReplyTo[$cur][1] = $name; 347 354 } 355 348 356 357 /** 358 * Find the name and address in the form "name<address@hop.tld>" 359 * @param string $address 360 * @return array( $name, $address ) 361 */ 362 function getAddrName($address) { 363 364 preg_match ('`^([^<]*)<([^>]*)>$`', $address, $tab ); 365 array_shift($tab); 366 return $tab; 367 368 } 349 369 370 /** 371 * Adds a Tpl référence. 372 * @param string $selector 373 * @return void 374 */ 375 function Tpl( $selector ) { 376 377 $this->bodyTpl = $selector; 378 379 } 380 350 381 ///////////////////////////////////////////////// 351 382 // MAIL SENDING METHODS 352 383 ///////////////////////////////////////////////// … … 361 392 $header = ""; 362 393 $body = ""; 363 394 $result = true; 395 396 if( isset($this->bodyTpl) && $this->bodyTpl != "") { 397 398 $mailtpl = new jTpl(); 399 $metas = $mailtpl->meta( $this->bodyTpl ); 400 401 if( isset($metas['Subject']) ) 402 $this->Subject = $metas['Subject']; 403 404 if( isset($metas['Priority']) ) 405 $this->Priority = $metas['Priority']; 406 $mailtpl->assign('Priority', $this->Priority ); 407 408 if( isset($metas['From']) ) { 409 $adr = $this->getAddrName( $metas['From'] ); 410 $this->From = $adr[1]; 411 $this->FromName = $adr[0]; 412 } 413 $mailtpl->assign('From', $this->From ); 414 $mailtpl->assign('FromName', $this->FromName ); 415 416 if( isset($metas['Sender']) ) 417 $this->Sender = $metas['Sender']; 418 $mailtpl->assign('Sender', $this->Sender ); 419 420 if( isset($metas['to']) ) 421 foreach( $metas['to'] as $val ) 422 $this->to[] = $this->getAddrName( $val ); 423 $mailtpl->assign('to', $this->to ); 424 425 if( isset($metas['cc']) ) 426 foreach( $metas['cc'] as $val ) 427 $this->cc[] = $this->getAddrName( $val ); 428 $mailtpl->assign('cc', $this->cc ); 429 430 if( isset($metas['bcc']) ) 431 foreach( $metas['bcc'] as $val ) 432 $this->bcc[] = $this->getAddrName( $val ); 433 $mailtpl->assign('bcc', $this->bcc ); 434 435 if( isset($metas['ReplyTo']) ) 436 foreach( $metas['ReplyTo'] as $val ) 437 $this->ReplyTo[] = $this->getAddrName( $val ); 438 $mailtpl->assign('ReplyTo', $this->ReplyTo ); 439 440 $this->Body = $mailtpl->fetch( $this->bodyTpl ); 441 442 } 364 443 365 444 if((count($this->to) + count($this->cc) + count($this->bcc)) < 1) 366 445 {
