Swiftmailer没有发送电子邮件,这里有错误消息:
Expected response code 250 but got code "421", with message "421 4.3.0 collect: Cannot write ./dfs89F9xKs038683 (bfcommit, uid=0, gid=118): No such file or directory "#0 /var/www/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(281): Swift_Transport_AbstractSmtpTransport->_assertResponseCode('421 4.3.0 colle...', Array) #1 /var/www/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php(245): Swift_Transport_AbstractSmtpTransport->executeCommand('??.??', Array, Array) #2 /var/www/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(335): Swift_Transport_EsmtpTransport->executeCommand('??.??', Array) #3 /var/www/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(433): Swift_Transport_AbstractSmtpTransport->_streamMessage(Object(Swift_Message)) #4 /var/www/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(449): Swift_Transport_AbstractSmtpTransport->_doMailTransaction(Object(Swift_Message), 'office@sajacarg...', Array, Array) #5 /var/www/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(176): Swift_Transport_AbstractSmtpTransport->_sendTo(Object(Swift_Message), 'office@sajacarg...', Array, Array) #6 /var/www/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer.php(86): Swift_Transport_AbstractSmtpTransport->send(Object(Swift_Message), Array) #7 /var/www/src/SajaCargo/MainBundle/Controller/ShipmentController.php(37): Swift_Mailer->send(Object(Swift_Message)) #8 [internal function]: SajaCargo\MainBundle\Controller\ShipmentController->indexAction() #9 /var/www/app/bootstrap.php.cache(2929): call_user_func_array(Array, Array) #10 /var/www/app/bootstrap.php.cache(2901): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #11 /var/www/app/bootstrap.php.cache(3040): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #12 /var/www/app/bootstrap.php.cache(2307): Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #13 /var/www/web/app.php(27): Symfony\Component\HttpKernel\Kernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #14 {main}
我试过这些配置:
swiftmailer:
transport: smtp
username: ~
password: ~
host: localhost
port: false
和
swiftmailer:
transport: sendmail
php mail()工作正常
编辑: 这是我的代码:
try {
$message = \Swift_Message::newInstance()
->setSubject('Shipment ID: confirmation')
->setFrom('office@company.com')
->setTo('myemail@email.com')
->setBody('test');
$this->get('mailer')->send($message);
} catch (\Exception $e) {
return new Response("email error:".$e->getMessage());
}
当我将Swift_Message更改为Swift_SendmailTransport时,我只看到空白页(没有错误),但电子邮件仍未发送
答案 0 :(得分:0)
从您的评论中,您最好使用sendmail
作为传输代理。
swiftmailer:
transport: sendmail
username: ~
password: ~
host: localhost
port: false
http://swiftmailer.org/docs/sending.html#using-the-sendmail-transport