Pimcore\Mail::send PHP Method

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
    public function send($transport = null)
    {
        $this->setSubject($this->getSubjectRendered());
        $bodyHtmlRendered = $this->getBodyHtmlRendered();
        if ($bodyHtmlRendered) {
            $this->setBodyHtml($bodyHtmlRendered);
        }
        $bodyTextRendered = $this->getBodyTextRendered();
        if ($bodyTextRendered) {
            $this->setBodyText($bodyTextRendered);
        }
        if ($this->ignoreDebugMode == false) {
            $this->checkDebugMode();
        }
        return $this->sendWithoutRendering($transport);
    }

Usage Example

 /**
  * @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();
 }
All Usage Examples Of Pimcore\Mail::send