send() public method

IMPORTANT: If the debug mode is enabled in "Settings" -> "System" -> "Debug" all emails will be sent to the debug email addresses that are given in "Settings" -> "System" -> "Email Settings" -> "Debug email addresses" set DefaultTransport or the internal mail function if no default transport had been set.
public send ( Zend_Mail_Transport_Abstract $transport = null ) : Mail
$transport Zend_Mail_Transport_Abstract
return Mail Provides fluent interface
 /**
  * @param object $participation
  * @return void
  * @throws \Exception
  */
 public function sendEmail($participation)
 {
     $email = $participation->getEmail();
     $emailDomain = trim(strtolower(preg_replace('/^[^@]+@/', '', $email)));
     $participation->setEmailDomain($emailDomain);
     $participation->save();
     $confirmationLink = $this->createConfirmationLink($participation->getConfirmationCode());
     $parameters = array('confirmationLink' => $confirmationLink, 'participationId' => $participation->getId());
     $emailDocumentPath = Plugin::getConfig()->get('emailDocumentPath');
     $emailDocument = DocumentModel::getByPath($emailDocumentPath);
     if (!$emailDocument instanceof EmailDocument) {
         throw new \Exception("Error: emailDocumentPath [{$emailDocumentPath}] " . "is not a valid email document.");
     }
     $mail = new Mail();
     $mail->addTo($email);
     if ($this->getSubject()) {
         $mail->setSubject($this->getSubject());
     }
     $mail->setDocument($emailDocumentPath);
     $mail->setParams($parameters);
     $mail->send();
     $note = new Note();
     $note->setElement($participation);
     $note->setDate(time());
     $note->setType("confirmation");
     $note->setTitle("Email sent");
     $note->addData("email", "text", $email);
     $note->setUser(0);
     $note->save();
 }
Exemplo n.º 2
0
 public function requestPasswordReset()
 {
     $this->setResetHash($this->createHash());
     $this->save();
     $doc = Email::getByPath(Config::get('emails')->passwordReset);
     if (!$doc) {
         throw new \Exception('No password reset email defined');
     }
     /** @var \Zend_Controller_Request_Http $request */
     $request = \Zend_Controller_Front::getInstance()->getRequest();
     $email = new Mail();
     $email->addTo($this->getEmail());
     $email->setDocument($doc);
     $email->setParams(['host' => sprintf('%s://%s', $request->getScheme(), $request->getHttpHost()), 'member_id' => $this->getId()]);
     $email->send();
     return $this;
 }
Exemplo n.º 3
0
 /**
  * Callback for 'member.register.post' event.
  * Sending email with confirmation links.
  *
  * @param \Zend_EventManager_Event $event
  * @return \Member
  * @throws \Exception
  */
 public static function confirm(\Zend_EventManager_Event $event)
 {
     /** @var \Member $member */
     $member = $event->getTarget();
     $member->setConfirmHash($member->createHash());
     $member->save();
     $doc = Email::getByPath(Config::get('emails')->registerConfirm);
     if (!$doc) {
         throw new \Exception('No confirmation email defined');
     }
     /** @var \Zend_Controller_Request_Http $request */
     $request = \Zend_Controller_Front::getInstance()->getRequest();
     $email = new Mail();
     $email->addTo($member->getEmail());
     $email->setDocument($doc);
     $email->setParams(['host' => sprintf('%s://%s', $request->getScheme(), $request->getHttpHost()), 'member_id' => $member->getId()]);
     $email->send();
     return $member;
 }
Exemplo n.º 4
0
 public function contactFormAction()
 {
     $success = false;
     if ($this->getParam("provider")) {
         $adapter = Tool\HybridAuth::authenticate($this->getParam("provider"));
         if ($adapter) {
             $user_data = $adapter->getUserProfile();
             if ($user_data) {
                 $this->setParam("firstname", $user_data->firstName);
                 $this->setParam("lastname", $user_data->lastName);
                 $this->setParam("email", $user_data->email);
                 $this->setParam("gender", $user_data->gender);
             }
         }
     }
     // getting parameters is very easy ... just call $this->getParam("yorParamKey"); regardless if's POST or GET
     if ($this->getParam("firstname") && $this->getParam("lastname") && $this->getParam("email") && $this->getParam("message")) {
         $success = true;
         $mail = new Mail();
         $mail->setIgnoreDebugMode(true);
         // To is used from the email document, but can also be set manually here (same for subject, CC, BCC, ...)
         //$mail->addTo("*****@*****.**");
         $emailDocument = $this->document->getProperty("email");
         if (!$emailDocument) {
             $emailDocument = Document::getById(38);
         }
         $mail->setDocument($emailDocument);
         $mail->setParams($this->getAllParams());
         $mail->send();
     }
     // do some validation & assign the parameters to the view
     foreach (["firstname", "lastname", "email", "message", "gender"] as $key) {
         if ($this->getParam($key)) {
             $this->view->{$key} = htmlentities(strip_tags($this->getParam($key)));
         }
     }
     // assign the status to the view
     $this->view->success = $success;
 }
Exemplo n.º 5
0
 /**
  * @param $object
  * @param $mailDocument
  * @param array $params
  * @throws \Exception
  */
 public function sendConfirmationMail($object, $mailDocument, $params = [])
 {
     $defaultParameters = ["gender" => $object->getGender(), 'firstname' => $object->getFirstname(), 'lastname' => $object->getLastname(), "email" => $object->getEmail(), 'token' => $object->getProperty("token"), "object" => $object];
     $params = array_merge($defaultParameters, $params);
     $mail = new Mail();
     $mail->addTo($object->getEmail());
     $mail->setDocument($mailDocument);
     $mail->setParams($params);
     $mail->send();
 }
Exemplo n.º 6
0
 public function sendTestEmailAction()
 {
     if (!$this->getUser()->isAllowed("emails")) {
         throw new \Exception("Permission denied, user needs 'emails' permission.");
     }
     $mail = new Mail();
     $mail->addTo($this->getParam("to"));
     $mail->setSubject($this->getParam("subject"));
     $mail->setIgnoreDebugMode(true);
     if ($this->getParam("type") == "text") {
         $mail->setBodyText($this->getParam("content"));
     } else {
         $mail->setBodyHtml($this->getParam("content"));
     }
     $mail->send();
     $this->_helper->json(array("success" => true));
 }