src/snac/server/mailer/Mailer.php
/**
     * Send Mail to User
     *
     * Sends an email with body and subject to the given User object.
     *
     * @param \snac\data\User $toUser The user to send an email to
     * @param string $subject The subject of the email
     * @param string $body The body of the email (in HTML)
     */
Send Mail to User
Sends an email with body and subject to the given User object.

@param \snac\data\User $toUser The user to send an email to
@param string $subject The subject of the email
@param string $body The body of the email (in HTML)
Send Mail to User Sends an email with body and subject to the given User object . @param \ snac \ data \ User $toUser The user to send an email to @param string $subject The subject of the email @param string $body The body of the email ( in HTML )
public function sendUserMail($toUser, $subject, $body) {
        $this->mailer->setFrom($this->fromEmail, $this->fromName);
        $toEmail = $toUser->getEmail();
        if ($toUser->getWorkEmail() !== null)
            $toEmail = $toUser->getWorkEmail();
        $this->mailer->addAddress($toEmail, $toUser->getFullName()); 
        $this->mailer->isHTML(true);                                            
        $this->mailer->Subject = $subject;
        $loader = new \Twig_Loader_Filesystem(\snac\Config::$EMAIL_TEMPLATE_DIR);
        $twig = new \Twig_Environment($loader, array());
        $htmlBody = $twig->render("default.html", array("body" => $body));
        $this->mailer->Body    = $htmlBody;
        $textBody = $twig->render("default.txt", array("body" => \Html2Text\Html2Text::convert($body)));
        $this->mailer->AltBody    = $textBody;
        if(!$this->mailer->send()) {
            $this->logger->addDebug('Message could not be sent: ' . $this->mailer->ErrorInfo);
        }
        $this->resetMailer();
    }
public function sendUserMail ( $ toUser , $ subject , $ body ) { $ this -> mailer -> setFrom ( $ this -> fromEmail , $ this -> fromName ) ; $ toEmail = $ toUser -> getEmail ( ) ; if ( $ toUser -> getWorkEmail ( ) !== null ) $ toEmail = $ toUser -> getWorkEmail ( ) ; $ this -> mailer -> addAddress ( $ toEmail , $ toUser -> getFullName ( ) ) ; $ this -> mailer -> isHTML ( true ) ; $ this -> mailer -> Subject = $ subject ; $ loader = new \ Twig_Loader_Filesystem ( \ snac \ Config :: $ EMAIL_TEMPLATE_DIR ) ; $ twig = new \ Twig_Environment ( $ loader , array ( ) ) ; $ htmlBody = $ twig -> render ( " default.html " , array ( " body " => $ body ) ) ; $ this -> mailer -> Body = $ htmlBody ; $ textBody = $ twig -> render ( " default.txt " , array ( " body " => \ Html2Text \ Html2Text :: convert ( $ body ) ) ) ; $ this -> mailer -> AltBody = $ textBody ; if ( ! $ this -> mailer -> send ( ) ) { $ this -> logger -> addDebug ( 'Message could not be sent: ' . $ this -> mailer -> ErrorInfo ) ; } $ this -> resetMailer ( ) ; }
Send Mail to User
 Sends an email with body and subject to the given User object.
Send Mail to User Sends an email with body and subject to the given User object .
// Add a recipient //$this->mailer->addAddress('ellen@example.com');                       // Name is optional //$this->mailer->addReplyTo('info@example.com', 'Information'); //$this->mailer->addCC('cc@example.com'); //$this->mailer->addBCC('bcc@example.com'); //$this->mailer->addAttachment('/var/tmp/file.tar.gz');                 // Add attachments //$this->mailer->addAttachment('/tmp/image.jpg', 'new.jpg');            // Optional name // Set email format to HTML // Use Twig to style the message body using the snac style