Esempio n. 1
0
 /**
  * Send a custom message created with chainable methods like to(), subject(),
  * etc.
  */
 public function send()
 {
     // Need to create a Message object to use a template
     $this->message = new Message(NULL, FALSE);
     $this->message->resetCustomVariables($this->customVariables);
     // Assuming the to address is the only one
     $to = $this->mailer->getToAddresses();
     $toName = $to[0][1];
     // Set custom variables
     $vars = ['FULL_NAME' => $toName, 'CONTENT_BODY' => $this->mailer->Body, 'SUBJECT' => $this->mailer->Subject];
     $this->message->setDefaultVars($vars);
     // Set subject and message body. They are applied to a template already
     // TODO: If the message chain is called twice (eg, creating the mail, setting the to address,
     // setting the subject, sending, setting another to address, sending again, this could cause
     // the subject and message to nest recursively, or not render correctly the second time around.
     $this->subject($this->message->getSubject());
     $this->message($this->message->getMessage());
     // Actual send
     return $this->sendMessage();
 }