Pimcore\Tool::getMail PHP Метод

getMail() публичный статический Метод

public static getMail ( null $recipients = null, null $subject = null, null $charset = null ) : Mail
$recipients null
$subject null
$charset null
Результат Mail
    public static function getMail($recipients = null, $subject = null, $charset = null)
    {
        $mail = new Mail($charset);
        if ($recipients) {
            if (is_string($recipients)) {
                $mail->addTo($recipients);
            } elseif (is_array($recipients)) {
                foreach ($recipients as $recipient) {
                    $mail->addTo($recipient);
                }
            }
        }
        if ($subject) {
            $mail->setSubject($subject);
        }
        return $mail;
    }

Usage Example

Пример #1
0
 public function lostpasswordAction()
 {
     $username = $this->getParam("username");
     if ($username) {
         $user = User::getByName($username);
         if (!$user instanceof User) {
             $this->view->error = "user unknown";
         } else {
             if ($user->isActive()) {
                 if ($user->getEmail()) {
                     $token = Tool\Authentication::generateToken($username, $user->getPassword());
                     $uri = $this->getRequest()->getScheme() . "://" . $this->getRequest()->getHttpHost();
                     $loginUrl = $uri . "/admin/login/login/?username="******"&token=" . $token . "&reset=true";
                     try {
                         $mail = Tool::getMail(array($user->getEmail()), "Pimcore lost password service");
                         $mail->setIgnoreDebugMode(true);
                         $mail->setBodyText("Login to pimcore and change your password using the following link. This temporary login link will expire in 30 minutes: \r\n\r\n" . $loginUrl);
                         $mail->send();
                         $this->view->success = true;
                     } catch (\Exception $e) {
                         $this->view->error = "could not send email";
                     }
                 } else {
                     $this->view->error = "user has no email address";
                 }
             } else {
                 $this->view->error = "user inactive";
             }
         }
     }
 }
All Usage Examples Of Pimcore\Tool::getMail