Beispiel #1
0
 /**
  * @param Contact $contact
  */
 public function setFromContact(Contact $contact)
 {
     /*
      * The From contact cannot have the FROM email since we don't want to sent emails directly from other users
      */
     $config = $this->getServiceManager()->get('config');
     $this->from = $config['email']['defaults']['from_email'];
     $this->replyTo = $contact->getEmail();
     $this->replyToName = $contact->getDisplayName();
     $this->fromName = sprintf("%s (via %s)", $contact->getDisplayName(), $config['email']['defaults']['from_name']);
 }
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 {
                     $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;
     }
 }
 /**
  * @param Contact $contact
  *
  * @return array
  */
 public function findOrganisationForProfileEditByContact(Contact $contact)
 {
     $organisations = [];
     //Start with your own organisation
     if (!is_null($contact->getContactOrganisation())) {
         $organisations[$contact->getContactOrganisation()->getOrganisation()->getId()] = $contact->getContactOrganisation()->getOrganisation();
     }
     foreach ($this->findOrganisationByEmailAddress($contact->getEmail()) as $organisation) {
         $organisations[$organisation->getId()] = $organisation;
     }
     asort($organisations);
     //Add an empty value
     $emptyOrganisation = new Entity\Organisation();
     $emptyOrganisation->setId(0);
     $emptyOrganisation->setOrganisation('— None of the above');
     $organisations[$emptyOrganisation->getId()] = $emptyOrganisation;
     return $organisations;
 }
Beispiel #4
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;
     }
 }