简体   繁体   中英

symfony fosuserBundle, unable to send confirmation mail after registration

Symfony seems to be unable to send confirmation mail, this is my code I tried everything but no result.

This is the code of config.yml :

fos_user:
    db_driver: orm 
    firewall_name: main
    user_class: BackOfficeBundle\Entity\User
    service:                               
        mailer: fos_user.mailer.twig_swift
    registration:
        confirmation:
            enabled: true
            from_email:
                address: '%mailer_user%'
                sender_name: '%mailer_user%'   
    from_email:
        address:  '%mailer_user%'
        sender_name: '%mailer_user%'

This is the code of parameters.yml :

parameters:
    database_host: 127.0.0.1
    database_port: null
    database_name: fos
    database_user: root
    database_password: null
    mailer_transport: gmail
    mailer_auth_mode: login
    mailer_encryption: ssl
    mailer_host: smtp.gmail.com
    mailer_user: mail.mail@gmail.com
    mailer_password: 000000
    secret: ThisTokenIsNotSoSecretChangeIt

This is the code of config_dev.yml :

swiftmailer:
    transport: gmail
    username:  '%mailer_user%'
    password:  '%mailer_password%'

The user is created and in description it said that i should check my email

Any suggestion is appreciated.

The issue probably comes from the fact that you're testing in a local environment without a valid certificate, thus you can't establish a secure connection to the Gmail server.

To make it work, try to:

  • Configure the Gmail account (it's preferable not to use your personal account) by creating an app password and allowing access to less secure apps, as described at the bottom of this page .
  • Add the verify_peer option set to false in the swiftmailer configuration:
#config_dev.yml

swiftmailer:
    transport: gmail
    username:  '%mailer_user%'
    password:  '%mailer_password%'
    stream_options:
        ssl:
            verify_peer: false

Note that this setup is not secure and should only be used in the dev environment for quick tests without sensitive data. You should also add the delivery_addresses option in swiftmailer configuration to send all mails to one address.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM