php - Where the mail is addressed within Symfony2?


I am implementing the SwiftmailerBundle and everything seems to work fine, but not really if the mail is sent . I wanted to ask where the mails are stored inside Symfony2 . I show my code:


# Swiftmailer Configuration
    transport: smtp
    username:  [email protected]   #my account 
    password:  ********    #my password
    spool:     { type: memory }


public function registroAction()
    $peticion = $this->getRequest();
    $em = $this->getDoctrine()->getManager();
    $user = new User(); //creo el usuario
    $datos = new Datos();
    $crearusuario = true;
    $formulario = $this->createForm(new RegistroUsuarioType(), $user);

    if ($peticion->getMethod() == 'POST') 

        $newuser = $this->get('request')->request->get('username'); //recupero el usuario ingresado
        $em = $this->getDoctrine()->getManager();
        $todos = $em->getRepository('AtajoBundle:User')->findByUsuario();

        foreach($todos as $todo)
            if($todo == $newuser)
                $crearusuario = false;

        if ($formulario->isValid() and $crearusuario != false) {
        $encoder = $this->get('security.encoder_factory')->getEncoder($user);
        $passwordCodificado = $encoder->encodePassword($user->getPassword(), $user->getSalt() );

        $em = $this->getDoctrine()->getManager();

        //si todo es correcto, busco el rol 'ROLE_USER' de la tabla ROLE..
        //y lo relaciono con el usuario.

        $role = $em->getRepository('ProyectoSeguridadBundle:Role')->findByRole('ROLE_USER');  //busco el rol
        $user->setRoles($role); //los relaciono
        $em->persist($user); //persisto el usuario

        $mail = $this->get('request')->request->get('email');
        $empresa = $this->get('request')->request->get('empresa');
        $cuit = $this->get('request')->request->get('cuit');
        $localidad = $this->get('request')->request->get('localidad');
        $calle = $this->get('request')->request->get('calle');
        $altura = $this->get('request')->request->get('altura');
        $telefono = $this->get('request')->request->get('telefono');
        $celular = $this->get('request')->request->get('celular');

        $message = \Swift_Message::newInstance()
        ->setSubject('Bienvenido a LM Lavoc')
        ->setFrom('[email protected]')
            array('name' => $newuser, 'mail' => $mail, 'empresa' => $empresa, 'cuit' => $localidad,
                'calle' => $calle, 'altura' => $altura, 'telefono' => $telefono, 'celular' => $celular)

        return $this->redirect($this->generateUrl('home'));

It is the function where the user is recorded , everything works fine , it's more , the information is stored in the database. The problem is not whether the mail is sent , and in any case , as I can see . I also want to verify if it's okay settings in config.yml , I use hotmail , not if the host and transport are correct. Thanks to all!




Option 1

There's an excellent cookbook article related to your question

That article has many ways to know if your mails are being sent or not ( Debugging on local server )

Option 2

You may want to look at Once you install this, you can just point the SMTP configuration to the one offered by mailcatcher and view all the mails that your app is sending

Option 3

As mentioned in your configuration, the spool is using memory .

Try changing it to a file based and set a path where the emails will be stored before they are delivered ( you need to runswiftmailer:spool:send command to really send the emails )


    default_mailer: default
            transport: %mailer_transport%
            host:      %mailer_host%
            username:  %mailer_user%
            password:  %mailer_password%
            port: %mailer_port%
                type: file
                path: "%kernel.root_dir%/spool"

People are also looking for solutions to the problem: php - Query to Json: Return Each Column Twice with Different Names


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.