Problem/Motivation

When trying to send a test mail : The website encountered an unexpected error. Try again later.

TypeError: Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport::setPassword(): Argument #1 ($password) must be of type string, null given, called in /data/web/xxxxxxxxxxxx/current/web/modules/contrib/symfony_mailer_office365/src/Office365EsmtpTransportFactory.php on line 57 in Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport->setPassword() (line 93 of /data/web/xxxxxxxxxxxx/current/vendor/symfony/mailer/Transport/Smtp/EsmtpTransport.php).

Steps to reproduce

Drupal 11.3.13
Install module
Set credentials in back office OR in settings.php
OAuth connect OK
Set transport type in policy
Try to send a test mail

Impossible to get Client secret in Office365EsmtpTransportFactory

CommentFileSizeAuthor
#2 symfony_mailer_office365_error.png140.89 KBattraktive
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

attraktive created an issue. See original summary.

attraktive’s picture

StatusFileSize
new140.89 KB

yusuf_khan made their first commit to this issue’s fork.

yusuf_khan’s picture

Hi @attraktive,

I opened an MR with a fix:
https://git.drupalcode.org/project/symfony_mailer_office365/-/merge_requ...

The issue appears to happen when the saved Symfony Mailer transport configuration does not contain the Office365 client secret, even though the module configuration does. In that case the DSN password becomes NULL and Symfony’s EsmtpTransport::setPassword() throws a TypeError.

The MR updates the transport plugin to fall back to the current Office365 module configuration when the saved transport configuration is missing values, and also guards the transport factory so setPassword() never receives NULL.

I ran PHP syntax checks and PHPCS on the touched files.

yusuf_khan’s picture

Status: Active » Needs review
attraktive’s picture

thanks ;) when will it be merged please ?

n1k’s picture

@attraktive If you could test this in your setup and verify that it fixes the issue, please set the issue status to "Reviewed & tested by the community", I will merge it then.

I'm also preparing a stable release, that I can hopefully get done in the next weeks.

attraktive’s picture

I've tested it yesterday, and it is doing the job thanks ;)

attraktive’s picture

Status: Needs review » Reviewed & tested by the community

  • a75ff977 committed on 1.x
    Issue #3606441: Prevent null Office365 client secret TypeError
    
n1k’s picture

Status: Reviewed & tested by the community » Fixed

Cool! Thanks everyone. Merged and I will create a new alpha release due to the severity on this one.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

n1k’s picture

Status: Fixed » Closed (fixed)