We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Flash messages not displaying after sending email with swiftmailer?

I have a similar problem as this thread here mentioned: https://stackoverflow.com/questions/21009488/symfony2-delayed-flashbag-message-when-sending-mail and I want to see if anybody encountered this problem before with phalcon?

just for reference here is my model:

<?php
require_once __DIR__ . '/../../vendor/swiftmailer/swiftmailer/lib/swift_required.php';
use
\Phalcon\DI;

class NotificationsEmail extends BaseModel
{

public function initialize()
{
    parent::initialize();
}

/**
 * Function use to send notification email
 *
 * @param string $email
 */    
public function sendConfirmationBooking($email, $teacherFirst, $studentFirst, $studentLast, $id){       
    // get data from config
    $contacts = $this->getDI()->get('config')->get('contacts')->get('contact-us');
    $gateway = $this->getDI()->get('config')->get('gmail-gateway');
    $subject = "Confirmation of Booking for Lesson";
    $name = 'confirmationBooking';

    // Create transport using smtp credential
    $transport = Swift_SmtpTransport::newInstance($gateway->host, $gateway->port, $gateway->security);
    $transport->setUsername($gateway->username);
    $transport->setPassword($gateway->password); 

    // Create the message
    $message = Swift_Message::newInstance();
    $message->setTo($email);
    $message->setSubject($subject);
    $message->setBody($this->getTemplateConfirmBooking($name, $teacherFirst, $studentFirst, $studentLast, $id),'text/html');
    $message->setFrom($contacts->from, $contacts->name);

    // Send the email
    $mailer = Swift_Mailer::newInstance($transport);
    $mailer->send($message);   
    return true;     
}

No matter what I returned from this back to the controller the flash messages will not show up, but the flash message will show up if I comment out this function in my controller.

edited Sep '15

Do you have echo $this->getContent() or (Volt version) in your view? If I'm not mistaken you need this to indicate where you want the message displayed.

I think I was using a double redirect with Ajax and PHP. Upon changing that the messages came back. Thanks for the help though.

Do you have echo $this->getContent() or (Volt version) in your view? If I'm not mistaken you need this to indicate where you want the message displayed.