Webform/SwiftMailer - TypeError in encodeString() - must be of the type string, array given I got into an issue while using a combination of SwiftMailer and Webform on Drupal 9. I found nothing helpfull while Googling and it took me a few days to figure out the issue. Hence I am sharing my findings with you.
My context:

Drupal 9.1.3
Webform 6.0.2 - with an Email Notification Handler
MailSystem 8.x-4.3 - Module: Webform / Formatter: Swift Mailer /
Sender: Swift Mailer
Swift Mailer 8.x-2.0 - set up to send SMTP emails

The problem:
The website encountered an unexpected error. Please try again later.
TypeError: Argument 1 passed to Swift_AddressEncoder_IdnAddressEncoder::encodeString() must be of the type string, array given, called in /home/www/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php on line 378 in Swift_AddressEncoder_IdnAddressEncoder-&gt;encodeString() (line 32 of vendor/swiftmailer/swiftmailer/lib/classes/Swift/AddressEncoder/IdnAddressEncoder.php).

How the problem manifested:

the error above was displayed on the website's footer
none of the AJAX driven features of the website didn't work - the ones from the admin interface, nor the ones in the front-end
The cause and my solution:
In the Webform's email handler configuration -&gt; &quot;Send from (website/domain)&quot; section -&gt; &quot;From email&quot; field, I used the [site:mail] token.
In EsmtpTransport.php line 378, the $address parameter had a value of [&quot;email@example.com&quot; =&gt; string(0)].
By modifying the &quot;From email&quot; field to &quot;Site email address&quot; solved my problem.
Hope this helps.