symfony fosuserBundle,注册后无法发送确认邮件

symfony fosuserBundle, unable to send confirmation mail after registration

Symfony 似乎无法发送确认邮件,这是我的代码 我尝试了所有方法但没有结果。

这是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%'

这是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

这是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

如有任何建议,我们将不胜感激。

问题可能是因为您在没有有效证书的情况下在本地环境中进行测试,因此您无法与 Gmail 服务器建立安全连接。

要让它发挥作用,请尝试:

  • 通过创建应用密码并允许访问安全性较低的应用来配置 Gmail 帐户(最好不要使用您的个人帐户),如 this page 底部所述。
  • 在 swiftmailer 配置中添加 verify_peer 选项设置为 false
#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.