SwiftMailer ReflectionException: Class Egulias\EmailValidator\EmailValidator 不存在
SwiftMailer ReflectionException: Class Egulias\EmailValidator\EmailValidator does not exist
SwiftMailer:反射异常
这个错误我想了半天,感觉什么都试过了。我从 SwiftMailer's Website 中复制了我遇到问题的部分的代码,但它仍然收到 ReflectionException。
一些背景细节:
Php 版本: 7
Swiftmailer 版本:6.0.0
PHP 使用 SwiftMailer 的代码
require_once 'swiftmailer-master/lib/swift_required.php';
$transport = (new Swift_SmtpTransport('smtp.gmail.com', 465, "ssl"))
->setUsername('my_gmail_username')
->setPassword('my_gmail_password');
$mailer = new Swift_Mailer($transport);
$message = (new Swift_Message())
->setSubject('Your subject')
->setFrom(['john@doe.com' => 'John Doe'])
->setTo(['receiver@domain.org', 'other@domain.org' => 'A name'])
->setBody('Here is the message itself')
我遇到的错误
[07-Jun-2017 17:31:28 America/New_York] PHP Fatal error: Uncaught
ReflectionException: Class Egulias\EmailValidator\EmailValidator does not
exist in /home/johnjpra/public_html/php/swiftmailer-
master/lib/classes/Swift/DependencyContainer.php:309
Stack trace:
#0 /home/johnjpra/public_html/php/swiftmailer-
master/lib/classes/Swift/DependencyContainer.php(309): ReflectionClass-
>__construct('Egulias\EmailVa...')
#1 /home/johnjpra/public_html/php/swiftmailer-
master/lib/classes/Swift/DependencyContainer.php(323):
Swift_DependencyContainer->createNewInstance('email.validator')
#2 /home/johnjpra/public_html/php/swiftmailer-
master/lib/classes/Swift/DependencyContainer.php(114):
Swift_DependencyContainer->createSharedInstance('email.validator')
#3 /home/johnjpra/public_html/php/swiftmailer-
master/lib/classes/Swift/DependencyContainer.php(371):
Swift_DependencyContainer->lookup('email.validator')
#4 /home/johnjpra/public_html/php/swiftmailer-
master/lib/classes/Swift/DependencyContainer.php(348):
Swift_DependencyContainer->lookupRecursive('email.validator')
#5 /home/johnjpra/pu in /home/johnjpra/public_html/php/swiftmailer-
master/lib/classes/Swift/DependencyContainer.php on line 309
我很想弄清楚这个问题。在此先感谢评论或回答此问题的任何人
您缺少 egulias/email-validator
包裹。
在 SwiftMailer 的 composer.json
中你可以看到它有这个依赖。
"require": {
"php": ">=7.0.0",
"egulias/email-validator": "~2.0"
},
我知道这是一个有两年历史的问题,但我最近 运行 进入了这个问题。
看来问题是包中某处被设置为绝对路径而不是相对路径。
我通过将我需要的 composer.json 复制到我正在使用的文件夹中解决了这个问题。然后我安装了 composer。片刻之后我有了一个工作的 swiftmailer。
SwiftMailer:反射异常
这个错误我想了半天,感觉什么都试过了。我从 SwiftMailer's Website 中复制了我遇到问题的部分的代码,但它仍然收到 ReflectionException。
一些背景细节:
Php 版本: 7
Swiftmailer 版本:6.0.0
PHP 使用 SwiftMailer 的代码
require_once 'swiftmailer-master/lib/swift_required.php';
$transport = (new Swift_SmtpTransport('smtp.gmail.com', 465, "ssl"))
->setUsername('my_gmail_username')
->setPassword('my_gmail_password');
$mailer = new Swift_Mailer($transport);
$message = (new Swift_Message())
->setSubject('Your subject')
->setFrom(['john@doe.com' => 'John Doe'])
->setTo(['receiver@domain.org', 'other@domain.org' => 'A name'])
->setBody('Here is the message itself')
我遇到的错误
[07-Jun-2017 17:31:28 America/New_York] PHP Fatal error: Uncaught
ReflectionException: Class Egulias\EmailValidator\EmailValidator does not
exist in /home/johnjpra/public_html/php/swiftmailer-
master/lib/classes/Swift/DependencyContainer.php:309
Stack trace:
#0 /home/johnjpra/public_html/php/swiftmailer-
master/lib/classes/Swift/DependencyContainer.php(309): ReflectionClass-
>__construct('Egulias\EmailVa...')
#1 /home/johnjpra/public_html/php/swiftmailer-
master/lib/classes/Swift/DependencyContainer.php(323):
Swift_DependencyContainer->createNewInstance('email.validator')
#2 /home/johnjpra/public_html/php/swiftmailer-
master/lib/classes/Swift/DependencyContainer.php(114):
Swift_DependencyContainer->createSharedInstance('email.validator')
#3 /home/johnjpra/public_html/php/swiftmailer-
master/lib/classes/Swift/DependencyContainer.php(371):
Swift_DependencyContainer->lookup('email.validator')
#4 /home/johnjpra/public_html/php/swiftmailer-
master/lib/classes/Swift/DependencyContainer.php(348):
Swift_DependencyContainer->lookupRecursive('email.validator')
#5 /home/johnjpra/pu in /home/johnjpra/public_html/php/swiftmailer-
master/lib/classes/Swift/DependencyContainer.php on line 309
我很想弄清楚这个问题。在此先感谢评论或回答此问题的任何人
您缺少 egulias/email-validator
包裹。
在 SwiftMailer 的 composer.json
中你可以看到它有这个依赖。
"require": {
"php": ">=7.0.0",
"egulias/email-validator": "~2.0"
},
我知道这是一个有两年历史的问题,但我最近 运行 进入了这个问题。
看来问题是包中某处被设置为绝对路径而不是相对路径。
我通过将我需要的 composer.json 复制到我正在使用的文件夹中解决了这个问题。然后我安装了 composer。片刻之后我有了一个工作的 swiftmailer。