[SOLVED] Contact Form with Swift Mailer

Hey neos community,

i followed this instruction to create a simple contact form: http://neos.readthedocs.io/en/stable/HowTos/AddingSimpleContactForm.html

Then i install Swift Mailer with:

php composer.phar require neos/swiftmailer

I add this to Settings.yaml:

Neos:
  [...]
  SwiftMailer:
    transport:
      type: 'Swift_SmtpTransport'
      options:
        mboxPathAndFilename: '%FLOW_PATH_DATA%/Persistent/sent-mail'

But if i add a contact form and send it an error occures:

Call to a member function send() on null
Exception Code	0
Exception Type	Error
Thrown in File	Packages/Application/Neos.SwiftMailer/Classes/Message.php
Line	51

I tested it also with real mail data and without any Swift Mailer configuration: same error. It seems like neos ignores the configuration.

The SMTP transport needs server connection parameters, the mboxPathAndFilename option is for the aptly named mbox transport. So, if the config we cannot see here is indeed correct… you may have a package loading order problem.

Try ./flow configuration:show --type Settings --path 'Neos.SwiftMailer' and check if your settings are there. If not, make sure the package you define the settings in requires neos/ swiftmailer to make sure it’s loaded after that (and thus the default settings come before your own).

You can check the loading order with ./flow package:list --loading-order

1 Like

Thank you for your answer.

My mistake: the transport type in settings was actually ‘Neos\SwiftMailer\Transport\MboxTransport’, i copied the false snippet

I added now the correct smtp configurations (from symfony project with working swiftmailer configuration). Then i run ./flow configuration:show --type Settings --path 'Neos.SwiftMailer'

Configuration "Settings: Neos.SwiftMailer":

transport:
  type: Swift_SmtpTransport
  options:
    host: 88.80.***.***
    username: post@xyz.com
    password: 'mypassword'

I required neos/swiftmailer in neos root and in my own package. If i run ./flow package:list --loading-order the swiftmailer package does not appear.

ACTIVE PACKAGES:
 Neos.Diff                                3.3.3          
 neos.errormessages                       4.3.2          
 Neos.Utility.Files                       4.3.2          
 Neos.Utility.Pdo                         4.3.2          
 Neos.Utility.OpcodeCache                 4.3.2          
 Neos.Cache                               4.3.2          
 neos.utilityunicode                      4.3.2          
 Neos.Utility.ObjectHandling              4.3.2          
 Neos.Flow.Log                            4.3.2          
 Neos.Utility.Arrays                      4.3.2          
 Neos.Utility.MediaTypes                  4.3.2          
 Neos.Utility.Schema                      4.3.2          
 typo3fluid.fluid                         2.1.3          
 psr.httpmessage                          1.0.1          
 paragonie.randomcompat                   2.0.11         
 ramsey.uuid                              3.7.2          
 Doctrine.Common.Collections              1.4.0          
 doctrine.inflector                       1.2.0          
 doctrine.cache                           1.6.2          
 Doctrine.Common.Lexer                    1.0.1          
 doctrine.annotations                     1.4.0          
 doctrine.common                          2.7.3          
 Doctrine.DBAL                            2.5.13         
 doctrine.instantiator                    1.0.5          
 symfony.polyfillmbstring                 1.6.0          
 psr.log                                  1.0.2          
 symfony.debug                            3.0.9          
 symfony.console                          2.8.33         
 Doctrine.ORM                             2.5.14         
 symfony.yaml                             2.8.33         
 zendframework.zendeventmanager           3.2.0          
 zendframework.zendcode                   3.1.0          
 ocramius.packageversions                 1.2.0          
 ocramius.proxymanager                    2.0.4          
 doctrine.migrations                      1.3.1          
 symfony.domcrawler                       2.8.33         
 neos.composerplugin                      2.0.1          
 imagine.imagine                          0.6.3          
 Behat.Transliterator                     1.2.0          
 gedmo.doctrineextensions                 2.3.12         
 Neos.Eel                                 4.3.2          
 neos.utilitylock                         4.3.2          
 Neos.Flow                                4.3.2          
 Neos.FluidAdaptor                        4.3.2          
 Neos.Imagine                             3.0.2          
 Neos.Media                               3.3.3          
 Neos.Form                                4.1.1          
 Neos.ContentRepository                   3.3.3          
 Neos.Party                               4.0.1          
 Neos.Twitter.Bootstrap                   3.0.2          
 Neos.Setup                               4.0.1          
 Neos.Fusion                              3.3.3          
 Neos.Media.Browser                       3.3.3          
 Neos.Neos                                3.3.3          
 org.bovigo.vfs                           1.6.5          
 Neos.NodeTypes.BaseMixins                3.3.3          
 Neos.NodeTypes.Form                      3.3.3          
 Neos.Seo                                 2.0.3          
 Flowpack.Neos.FrontendLogin              3.0.2          
 Neos.NodeTypes.AssetList                 3.3.3          
 Neos.NodeTypes.ColumnLayouts             3.3.3          
 Neos.NodeTypes.ContentReferences         3.3.3          
 Neos.NodeTypes.Html                      3.3.3          
 Neos.NodeTypes.Navigation                3.3.3          
 Neos.NodeTypes                           3.3.3          
 Custom.Home                                                
 webmozart.assert                         1.2.0          
 phpdocumentor.reflectioncommon           1.0.1          
 phpdocumentor.typeresolver               0.4.0          
 phpdocumentor.reflectiondocblock         4.2.0          
 sebastian.diff                           1.4.3          
 sebastian.recursioncontext               3.0.0          
 sebastian.exporter                       3.1.0          
 sebastian.comparator                     2.0.0          
 phpspec.prophecy                         1.7.3          
 myclabs.deepcopy                         1.7.0          
 phpunit.phptimer                         1.0.9          
 phpunit.phpfileiterator                  1.4.5          
 phpunit.phptokenstream                   2.0.2          
 phpunit.phptexttemplate                  1.2.1          
 sebastian.codeunitreverselookup          1.0.1          
 sebastian.environment                    2.0.0          
 sebastian.version                        2.0.1          
 theseer.tokenizer                        1.1.0          
 phpunit.phpcodecoverage                  5.2.0          
 phpunit.phpunitmockobjects               4.0.4          
 sebastian.globalstate                    2.0.0          
 sebastian.objectreflector                1.1.1          
 sebastian.objectenumerator               3.0.3          
 sebastian.resourceoperations             1.0.0          
 phpunit.phpunit                          6.0.13         
 symfony.cssselector                      2.8.33         
 Neos.Behat                               dev-master     
 Neos.RedirectHandler                     2.0.0          
 Neos.RedirectHandler.DatabaseStorage     2.0.1          
 Neos.RedirectHandler.NeosAdapter         2.0.1          
 Neos.Neos.Ui.Compiled                    1.0.4          
 Neos.Neos.Ui                             1.0.4          
 Neos.Kickstarter                         4.3.2          
 Neos.SiteKickstarter                     3.3.3          

INACTIVE PACKAGES:
 Neos.Demo                                3.3.3

Okay, it’s always the same story: 1 minute after my answer i found the simple solution:

./flow flow:package:rescan

Now neos load my package after swiftmailer and it works!

Thank you Karsten for your help :slight_smile:

2 Likes