简体   繁体   English

Swiftmailer不发送电子邮件,但是php mail()可以正常工作

[英]Swiftmailer doesn't send email but php mail() works fine

Swiftmailer doesn't send email, here is error message: 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}

I tried with these configs: 我尝试了以下配置:

swiftmailer:
    transport: smtp
    username:  ~
    password:  ~
    host: localhost
    port: false

and

swiftmailer:
    transport: sendmail

php mail() works fine php mail()正常工作

EDIT: Here is my code: 编辑:这是我的代码:

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());

        }

when I've changed Swift_Message to Swift_SendmailTransport I see only blank, white page (no error) but email is still not send 当我将Swift_Message更改为Swift_SendmailTransport时,我只能看到空白的白页(无错误),但仍无法发送电子邮件

From your comment its better you use sendmail as transport agent. 根据您的意见,最好使用sendmail作为传输代理。

swiftmailer:
    transport: sendmail
    username:  ~
    password:  ~
    host: localhost
    port: false

http://swiftmailer.org/docs/sending.html#using-the-sendmail-transport http://swiftmailer.org/docs/sending.html#using-the-sendmail-transport

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM