| | 355 | |
|---|
| | 356 | function name_addr( $adresse, $type = 'addresse' ) { |
|---|
| | 357 | |
|---|
| | 358 | if( strpos($adresse, '<') === true ) { |
|---|
| | 359 | $tab = explode('>', $adresse); |
|---|
| | 360 | $tab = explode('<', $tab[1]); |
|---|
| | 361 | if( $type == 'addresse' && isset($tab[1]) ) return $tab[1]; |
|---|
| | 362 | if( $type == 'name') return $tab[0]; |
|---|
| | 363 | } |
|---|
| | 364 | else if( $type == 'name' ) return ''; |
|---|
| | 365 | else if( $type == 'addresse' ) return $adresse; |
|---|
| | 366 | |
|---|
| | 367 | } |
|---|
| | 394 | |
|---|
| | 395 | if( isset($this->bodyTpl) && $this->bodyTpl != "") { |
|---|
| | 396 | |
|---|
| | 397 | $mailtpl = new jTpl(); |
|---|
| | 398 | $metas = $mailtpl->meta( $this->bodyTpl ); |
|---|
| | 399 | |
|---|
| | 400 | if( isset($metas['Subject']) ) |
|---|
| | 401 | $this->Subject = $metas['Subject']; |
|---|
| | 402 | |
|---|
| | 403 | if( isset($metas['Priority']) ) |
|---|
| | 404 | $this->Priority = $metas['Priority']; |
|---|
| | 405 | $mailtpl->assign('Priority', $this->Priority ); |
|---|
| | 406 | |
|---|
| | 407 | if( isset($metas['From']) ) { |
|---|
| | 408 | $this->From = $this->name_addr( $metas['From'], 'addresse' ); |
|---|
| | 409 | $this->FromName = $this->name_addr( $metas['From'], 'name' ); |
|---|
| | 410 | } |
|---|
| | 411 | $mailtpl->assign('From', $this->From ); |
|---|
| | 412 | $mailtpl->assign('FromName', $this->FromName ); |
|---|
| | 413 | |
|---|
| | 414 | if( isset($metas['Sender']) ) |
|---|
| | 415 | $this->Sender = $metas['Sender']; |
|---|
| | 416 | $mailtpl->assign('Sender', $this->Sender ); |
|---|
| | 417 | |
|---|
| | 418 | if( isset($metas['to']) ) |
|---|
| | 419 | foreach( $metas['to'] as $val ) |
|---|
| | 420 | $this->AddAddress($this->name_addr($val, 'addresse'), $this->name_addr($val, 'name')); |
|---|
| | 421 | $mailtpl->assign('to', $this->to ); |
|---|
| | 422 | |
|---|
| | 423 | if( isset($metas['cc']) ) |
|---|
| | 424 | foreach( $metas['cc'] as $val ) |
|---|
| | 425 | $this->AddCC($this->name_addr($val, 'addresse'), $this->name_addr($val, 'name')); |
|---|
| | 426 | $mailtpl->assign('cc', $this->cc ); |
|---|
| | 427 | |
|---|
| | 428 | if( isset($metas['bcc']) ) |
|---|
| | 429 | foreach( $metas['bcc'] as $val ) |
|---|
| | 430 | $this->AddBCC($this->name_addr($val, 'addresse'), $this->name_addr($val, 'name')); |
|---|
| | 431 | $mailtpl->assign('bcc', $this->bcc ); |
|---|
| | 432 | |
|---|
| | 433 | if( isset($metas['ReplyTo']) ) |
|---|
| | 434 | foreach( $metas['ReplyTo'] as $val ) |
|---|
| | 435 | $this->AddReplyTo($this->name_addr($val, 'addresse'), $this->name_addr($val, 'name')); |
|---|
| | 436 | $mailtpl->assign('ReplyTo', $this->ReplyTo ); |
|---|
| | 437 | |
|---|
| | 438 | $this->Body = $mailtpl->fetch( $this->bodyTpl ); |
|---|
| | 439 | |
|---|
| | 440 | } |
|---|