Saturday, February 9, 2013

Symfony 2 SwiftMailer Spoof and Redirect Response Abnormal behavior

Specs:
  • Symfony 2.1.x
  • FOSUserBundle
  • SwiftMailer
I was trying to modify the registration flow in FOSUserBundle to do two things:
  • After a user registers, he/she will be logged in automatically (no need to confirm emails)
  • Send an email to the user upon successful registration
However, I find that after the user registers, he/she is always redirected to the login page (I want them to be in an authenticated page). If the user refreshes this page (via the refresh button in the browser), they would be logged in.

After numerous hours of debugging, I found that if I turn off the memory spooling option in SwiftMailer, everything would work fine.

In app/config/config.yaml
swiftmailer:
    transport: %mailer_transport%
    encryption: %encryption%
    auth_mode: login
    host:      %mailer_host%
    username:  %mailer_user%
    password:  %mailer_password%
    #spool:     { type: memory }
If anyone knows why this is happening, please comment below.

3 comments:

  1. Hi i have the same problem. Did you found the reason?

    ReplyDelete
    Replies
    1. Hi this may help. https://github.com/symfony/symfony/issues/7380

      But what I have done is to use file spooling instead. It's better to separate the app server and email server anyways.

      Delete
  2. Ok i have found the real problem - it is described here: https://github.com/symfony/symfony/issues/6417

    maby it will help you

    ReplyDelete