ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilMimeMailNotification.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once 'Services/Mail/classes/class.ilMimeMail.php';
5 include_once 'Services/Mail/classes/class.ilMailNotification.php';
6 
14 {
18  protected $mime_mail;
19 
23  protected $current_recipient;
24 
28  public function sendMimeMail($a_rcp)
29  {
30  $this->mime_mail->To($a_rcp);
31  $this->mime_mail->Subject($this->getSubject());
32  $this->mime_mail->Body($this->getBody());
33  $this->mime_mail->Send();
34  }
35 
39  protected function initMimeMail()
40  {
44  global $ilSetting;
45 
46  $this->mime_mail = new ilMimeMail();
47  $this->mime_mail->From($ilSetting->get('admin_email'));
48  $this->mime_mail->autoCheck(false);
49 
50  return $this->mime_mail;
51  }
52 
56  protected function initLanguageByIso2Code($a_code = '')
57  {
58  parent::initLanguageByIso2Code($a_code);
59  $this->getLanguage()->loadLanguageModule('registration');
60  }
61 
65  protected function initLanguage($a_usr_id)
66  {
67  parent::initLanguage($a_usr_id);
68  $this->getLanguage()->loadLanguageModule('registration');
69  }
70 
75  protected function handleCurrentRecipient($rcp)
76  {
77  require_once 'Services/Mail/exceptions/class.ilMailException.php';
78 
79  if(is_numeric($rcp))
80  {
84  $rcp = ilObjectFactory::getInstanceByObjId($rcp, false);
85  if(!$rcp)
86  {
87  throw new ilMailException('no_recipient_found');
88  }
89  $this->setCurrentRecipient($rcp->getEmail());
90  $this->initLanguage($rcp->getId());
91  }
92  else if(is_string($rcp) && ilUtil::is_email($rcp))
93  {
94  $this->setCurrentRecipient($rcp);
95  $this->initLanguageByIso2Code();
96  }
97  else if($rcp instanceof ilObjUser)
98  {
102  $this->setCurrentRecipient($rcp->getEmail());
103  $this->initLanguage($rcp->getId());
104  }
105  else
106  {
107  throw new ilMailException('no_recipient_found');
108  }
109  }
110 
115  {
116  $this->current_recipient = $current_recipient;
117  return $this;
118  }
119 
123  public function getCurrentRecipient()
124  {
126  }
127 
132  public function setMimeMail($mime_mail)
133  {
134  $this->mime_mail = $mime_mail;
135  return $this;
136  }
137 
141  public function getMimeMail()
142  {
143  return $this->mime_mail;
144  }
145 }
static is_email($a_email)
This preg-based function checks whether an e-mail address is formally valid.
Class ilMailException.
Base class for course/group mail notifications.
this class encapsulates the PHP mail() function.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Base class for mime mail notifications.
global $ilSetting
Definition: privfeed.php:17