Problem/Motivation

DSN transports can't be created on the form

Steps to reproduce

Add a new transport with a valid DSN and get the following error

You have requested a non-existent service "Symfony\Component\Mailer\Transport".

Proposed resolution

use the static method "Symfony\Component\Mailer\Transport::fromDsn"

Remaining tasks

Code

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

rodrigoaguilera created an issue. See original summary.

rodrigoaguilera’s picture

Status: Active » Needs review
adamps’s picture

Status: Needs review » Needs work

Thanks well spotted.

Calling Transport::fromDsn creates a new Transport object based on the `getDefaultFactories`.

What we actually want to use are the Drupal configured transport services, which exist in $MultiTransport->transportFactory. This will pick up all services tagged mailer.transport_factory including the SendmailCommandValidationTransportFactory decoration. Maybe we could add MultiTransport::validateDsn() to validate using this collection?

adamps’s picture

Assigned: Unassigned » adamps
adamps’s picture

Status: Needs work » Needs review

@rodrigoaguilera Please feel free to take a look and let me know if it works for you. Otherwise I'll check in before I make the next release.

adamps’s picture

Assigned: adamps » Unassigned
rodrigoaguilera’s picture

Status: Needs review » Reviewed & tested by the community

I checked out fa24d4c6407eb0bacaf08099be868b938717e6e6 and succesfully created a transport with the interface.
The code look good. I don't really use the architecture with the tagged services but I guess is important for flexibility opening the door for things like decorating.

adamps’s picture

Status: Reviewed & tested by the community » Fixed

Great thanks

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.