我正在使用Symfony开发应用程序,我想为每个注册发送验证电子邮件。这是我的代码:
#config.yml
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: AppBundle\Entity\User
from_email:
address: "example@mail.com"
sender_name: Demo Registration
registration:
confirmation:
enabled: true
service:
mailer: fos_user.mailer.default
email_canonicalizer: fos_user.util.canonicalizer.default
token_generator: fos_user.util.token_generator.default
username_canonicalizer: fos_user.util.canonicalizer.default
user_manager: fos_user.user_manager.default
#parameters.yml
parameters:
database_host: 127.0.0.1
database_port: null
database_name: @name
database_user: @user
database_password: @password
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: @mail
mailer_password: @password
secret: @secret
我想将gmail用作电子邮件发件人。 谢谢你的帮助。
答案 0 :(得分:1)
您需要提供有效的电子邮件帐户,否则系统无法发送任何邮件。
您需要在parameters.yml
中提供信息mailer_transport: smtp
mailer_host: YOUR EMAIL HOST
mailer_user: YOUR EMAIL USER
mailer_password: YOUR EMAIL PASS
- 更新 -
尝试正确格式化config.yml:
service:
mailer: fos_user.mailer.default
email_canonicalizer: fos_user.util.canonicalizer.default
token_generator: fos_user.util.token_generator.default
username_canonicalizer: fos_user.util.canonicalizer.default
user_manager: fos_user.user_manager.default
而不是
service:
mailer: fos_user.mailer.default
email_canonicalizer: fos_user.util.canonicalizer.default
token_generator: fos_user.util.token_generator.default
username_canonicalizer: fos_user.util.canonicalizer.default
user_manager: fos_user.user_manager.default