Search code examples
symfonyswiftmailerhyper-v

Swiftmailer does not send from Hyper-V virtual machine


A Hyper-V machine with Ubuntu 18 has a Symfony 4.3 app with SwiftMailer. Attempts to send an email from the command line with php bin/console swiftmailer:email:send result in

[OK] 1 emails were successfully sent.

although mail.log contains this

localhost sm-mta[5847]: xBBFThub005847: localhost [127.0.0.1] did not issue MAIL/EXPN/VRFY/ETRN during connection to MTA-v4

and the email is never received.

.env.local contains

MAILER_URL=gmail://username@gmail.com:password@localhost?encryption=tls&auth_mode=oauth

.../config/packages/swiftmailer.yaml:

swiftmailer:
    default_mailer: memory
    mailers:
        memory:
            sender_address: 'admin@bogus.info'
            transport:        smtp
            spool: { type: 'memory' }
        spooler:
                sender_address: 'admin@bogus.info'
                transport:        smtp
                spool:
                    type: file
                    path: '%kernel.project_dir%/var/spool'

Using the identical configuration from the host DOES deliver mail.


Solution

  • While the eventual solution may be excessive it is effective. I first tried installing sendmail but that went nowhere. Purged it and installed postfix following this tutorial on using postfix to relay to gmail. When a test message failed I followed the answer provide by kjones at this site. Allowed "Access for less secure apps setting" at gmail and all is now well.

    All this for a practice go-live run!