'服务定义" smtp.gmail.com"不存在。'

时间:2016-01-10 12:04:37

标签: php symfony email

我刚安装了Symfony,但电子邮件配置存在问题:

Fatal error: Uncaught exception 'Symfony\Component\DependencyInjection\Exception\InvalidArgumentException' with message 'The service definition "smtp.gmail.com" does not exist.' in C:\Xampp\htdocs\symfony-project\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\ContainerBuilder.php:766
Stack trace:
#0 C:\Xampp\htdocs\symfony-project\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Compiler\ReplaceAliasByActualDefinitionPass.php(46): Symfony\Component\DependencyInjection\ContainerBuilder->getDefinition('smtp.gmail.com')
#1 C:\Xampp\htdocs\symfony-project\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Compiler\ReplaceAliasByActualDefinitionPass.php(63): Symfony\Component\DependencyInjection\Compiler\ReplaceAliasByActualDefinitionPass->process(Object(Symfony\Component\DependencyInjection\ContainerBuilder))
#2 C:\Xampp\htdocs\symfony-project\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Compiler\ReplaceAliasByActualDefinitionPass.php(63): Symfony\Component\D in C:\Xampp\htdocs\symfony-project\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Compiler\ReplaceAliasByActualDefinitionPass.php on line 48

1 个答案:

答案 0 :(得分:2)

如果您需要帮助,您应该共享包含'smtp.gmail.com'的代码 它可能是您的配置中的错误,或者只是您的依赖项中的错误。

为避免疑问,请删除以下文件:

  • composer.lock
  • /vendor(目录)
  • /app/cache/*

然后运行composer update 如果问题仍然存在,请验证您的电子邮件配置如下所示:

// app/config/config.yml
swiftmailer:
    host: "%mailer_host%"

// app/config/parameters.yml
mailer_host: smtp.gmail.com
mailer_encryption: ssl

How use Gmail to send emails in Symfony
如果问题仍然存在,请在您的问题中分享您的配置代码。