Beispiel #1
0
 /**
  * Send the email.
  */
 public function send()
 {
     switch ($this->email->isPersonal()) {
         case true:
             foreach ($this->email->getTo() as $recipient => $contact) {
                 /*
                  * Create a new message for everyone
                  */
                 $this->message = new Message();
                 $this->message->setEncoding('UTF-8');
                 $this->generateMessage();
                 //add the CC and BCC to the email
                 $this->setShadowRecipients();
                 /*
                  * We have a recipient which can be an instance of the contact. Produce a contactService object
                  * and fill the templateVars with extra options
                  */
                 if ($contact instanceof Contact) {
                     $this->updateTemplateVarsWithContact($contact);
                 } else {
                     $contactName = $contact;
                     $contact = new Contact();
                     $contact->setEmail($recipient);
                     if (!is_null($contactName)) {
                         $contact->setFirstName($contactName);
                     }
                 }
                 /*
                  * Overrule the to when we are in development
                  */
                 if (!defined("DEBRANOVA_ENVIRONMENT") || 'development' === DEBRANOVA_ENVIRONMENT) {
                     $this->message->addTo($this->config["emails"]["admin"], $contact->getDisplayName());
                 } else {
                     $this->message->addTo($contact->getEmail(), $contact->getDisplayName());
                 }
                 //$this->message->addTo($contact->getEmail(), $contact->getDisplayName());
                 /*
                  * We have the contact and can now produce the content of the message
                  */
                 $this->parseSubject();
                 /*
                  * We have the contact and can now produce the content of the message
                  */
                 $this->parseBody();
                 /*
                  * Send the email
                  */
                 $this->transport->send($this->message);
             }
             break;
         case false:
             /*
              * Create a new message for everyone
              */
             $this->message = new Message();
             $this->message->setEncoding('UTF-8');
             $this->generateMessage();
             //add the CC and BCC to the email
             $this->setShadowRecipients();
             foreach ($this->email->getTo() as $recipient => $contact) {
                 /*
                  * We have a recipient which can be an instance of the contact. Produce a contactService object
                  * and fill the templateVars with extra options
                  */
                 if (!$contact instanceof Contact) {
                     $contactName = $contact;
                     $contact = new Contact();
                     $contact->setEmail($recipient);
                     $contact->setFirstName($contactName);
                 }
                 /*
                  * Overrule the to when we are in development
                  */
                 if (!defined("DEBRANOVA_ENVIRONMENT") || 'development' === DEBRANOVA_ENVIRONMENT) {
                     $this->message->addTo($this->config["emails"]["admin"], $contact->getDisplayName());
                 } else {
                     $this->message->addTo($contact->getEmail(), $contact->getDisplayName());
                 }
             }
             /*
              * We have the contact and can now produce the content of the message
              */
             $this->parseSubject();
             /*
              * We have the contact and can now produce the content of the message
              */
             $this->parseBody();
             /*
              * Send the email
              */
             $this->transport->send($this->message);
             break;
     }
 }
Beispiel #2
0
 /**
  * Send the email.
  */
 public function send()
 {
     switch ($this->email->isPersonal()) {
         case true:
             foreach ($this->email->getTo() as $recipient => $contact) {
                 /*
                  * Create a new message for everyone
                  */
                 $this->message = new Message();
                 $this->message->setEncoding('UTF-8');
                 $this->generateMessage();
                 //add the CC and BCC to the email
                 $this->setShadowRecipients();
                 /*
                  * We have a recipient which can be an instance of the contact. Produce a contactService object
                  * and fill the templateVars with extra options
                  */
                 if ($contact instanceof Contact) {
                     $this->updateTemplateVarsWithContact($contact);
                 } else {
                     $contact = new Contact();
                     $contact->setEmail($recipient);
                 }
                 /*
                  * Overrule the to when we are in development
                  */
                 if (!defined("DEBRANOVA_ENVIRONMENT") || 'development' === DEBRANOVA_ENVIRONMENT) {
                     $this->message->addTo('*****@*****.**', $contact->getDisplayName());
                 } else {
                     $this->message->addTo($contact->getEmail(), !is_null($contact->getId()) ? $contact->getDisplayName() : null);
                 }
                 /**
                  * We have the contact and can now produce the content of the message
                  */
                 $this->parseSubject();
                 /**
                  * If we have a deeplink, parse it
                  */
                 $this->parseDeeplink();
                 /**
                  * If we have an unsubscribe, parse it
                  */
                 $this->parseUnsubscribe();
                 /**
                  * We have the contact and can now produce the content of the message
                  */
                 $this->parseBody();
                 /**
                  * Send the email
                  */
                 $this->transport->send($this->message);
             }
             break;
         case false:
             /*
              * Create a new message for everyone
              */
             $this->message = new Message();
             $this->message->setEncoding('UTF-8');
             $this->generateMessage();
             //add the CC and BCC to the email
             $this->setShadowRecipients();
             foreach ($this->email->getTo() as $recipient => $contact) {
                 /*
                  * We have a recipient which can be an instance of the contact. Produce a contactService object
                  * and fill the templateVars with extra options
                  */
                 if (!$contact instanceof Contact) {
                     $contact = new Contact();
                     $contact->setEmail($recipient);
                 }
                 /*
                  * Overrule the to when we are in development
                  */
                 if (!defined("DEBRANOVA_ENVIRONMENT") || 'development' === DEBRANOVA_ENVIRONMENT) {
                     $this->message->addTo('*****@*****.**', $contact->getDisplayName());
                 } else {
                     $this->message->addTo($contact->getEmail(), !is_null($contact->getId()) ? $contact->getDisplayName() : null);
                 }
             }
             /*
              * We have the contact and can now produce the content of the message
              */
             $this->parseSubject();
             /**
              * If we have a deeplink, parse it
              */
             $this->parseDeeplink();
             /**
              * If we have an unsubscribe, parse it
              */
             $this->parseUnsubscribe();
             /*
              * We have the contact and can now produce the content of the message
              */
             $this->parseBody();
             /*
              * Send the email
              */
             $this->transport->send($this->message);
             break;
     }
 }