我正在使用yii 2高级模板,在注册发送邮件时遇到了问题。我已经使用mailtrap发送邮件,并在common/config/mainlocal-php中包含了所有细节。使用Xampp作为主机。
php看起来像这样:
<?php
return [
'components' => [
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=advanced_yii2',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
],
'mail' => [
'class' => 'yii\swiftmailer\Mailer',
'viewPath' => '@common/mail',
'useFileTransport' => false,
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'smtp.mailtrap.io',
'username' => '9**************e',
'password' => '7***************5',
'port' => '2525',
'encryption' => 'tls',
],
],
],
];
This is the error i am getting.
Swift_TransportException
Process could not be started [The system cannot find the path specified.
]
1. in C:\xampp\htdocs\yii-application\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\StreamBuffer.php at line 299
2. in C:\xampp\htdocs\yii-application\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\StreamBuffer.php at line 54 – Swift_Transport_StreamBuffer::establishProcessConnection()
3. in C:\xampp\htdocs\yii-application\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\AbstractSmtpTransport.php at line 143 – Swift_Transport_StreamBuffer::initialize(['timeout' => 30, 'blocking' => 1, 'command' => '/usr/sbin/sendmail -bs', 'type' => 16])
4. in C:\xampp\htdocs\yii-application\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\SendmailTransport.php at line 50 – Swift_Transport_AbstractSmtpTransport::start()
5. in C:\xampp\htdocs\yii-application\vendor\yiisoft\yii2-swiftmailer\src\Mailer.php at line 113 – Swift_Transport_SendmailTransport::start()
6. in C:\xampp\htdocs\yii-application\vendor\yiisoft\yii2-swiftmailer\src\Mailer.php at line 156 – yii\swiftmailer\Mailer::getSwiftMailer()
7. in C:\xampp\htdocs\yii-application\vendor\yiisoft\yii2\mail\BaseMailer.php at line 263 – yii\swiftmailer\Mailer::sendMessage(yii\swiftmailer\Message)
8. in C:\xampp\htdocs\yii-application\vendor\yiisoft\yii2\mail\BaseMessage.php at line 49 – yii\mail\BaseMailer::send(yii\swiftmailer\Message)
9. in C:\xampp\htdocs\yii-application\frontend\models\SignupForm.php at line 77 – yii\mail\BaseMessage::send()
10. in C:\xampp\htdocs\yii-application\frontend\models\SignupForm.php at line 57 – frontend\models\SignupForm::sendEmail(common\models\User)
11. in C:\xampp\htdocs\yii-application\frontend\controllers\SiteController.php at line 156 – frontend\models\SignupForm::signup()
12. frontend\controllers\SiteController::actionSignup()
13. in C:\xampp\htdocs\yii-application\vendor\yiisoft\yii2\base\InlineAction.php at line 57 – call_user_func_array([frontend\controllers\SiteController, 'actionSignup'], [])
14. in C:\xampp\htdocs\yii-application\vendor\yiisoft\yii2\base\Controller.php at line 157 – yii\base\InlineAction::runWithParams(['r' => 'site/signup'])
15. in C:\xampp\htdocs\yii-application\vendor\yiisoft\yii2\base\Module.php at line 528 – yii\base\Controller::runAction('signup', ['r' => 'site/signup'])
16. in C:\xampp\htdocs\yii-application\vendor\yiisoft\yii2\web\Application.php at line 103 – yii\base\Module::runAction('site/signup', ['r' => 'site/signup'])
17. in C:\xampp\htdocs\yii-application\vendor\yiisoft\yii2\base\Application.php at line 386 – yii\web\Application::handleRequest(yii\web\Request)
18. in C:\xampp\htdocs\yii-application\frontend\web\index.php at line 17 – yii\base\Application::run()
2条答案
按热度按时间rseugnpd1#
我认为问题在
mail
中,您应该使用mailer
嵌套mail
例如:
这是documentation
qcbq4gxm2#
我已经通过我的swiftmailer帐户测试了这个设置,并可以确认通过注册提交的注册电子邮件到达了注册下输入的电子邮件帐户。因此,通过下面的mailtrap帐户,我设置和成功。我通常使用虚拟帐户,我在我的宽带提供商下设置,这样我就可以绕过hmailserver,我有困难设置。我使用端口25连接通过我的宽带提供商正常,所以我决定使用25的mailtrap以及。
顺便说一句,我正在使用sjaak/pluto进行注册,并对这个新模块非常满意。