After playing around with it a bit more, I came up with a solution that I like and that solves my issues
- Uses different transport configurations for contact and newsletter forms
- Works with Uniform
- Keeps the authentication information in the config
config.php
'smtp' => [
'info' => [
'type' => 'smtp',
'host' => 'smtp.example.com',
'port' => 587,
'security' => true,
'auth' => true,
'username' => 'info@example.com',
'password' => 'TopSneaky',
],
'newsletter' => [
'type' => 'smtp',
'host' => 'smtp.example.com',
'port' => 587,
'security' => true,
'auth' => true,
'username' => 'newsletter@example.com',
'password' => 'TopSneaky',
]
],
Contact Controller
$form->emailAction([
'to' => iconv("UTF-8", "ISO-8859-1", $form->data('email')),
'from' => 'info@example.com',
'fromName' => iconv("UTF-8", "ISO-8859-1", 'Supports öäü'),
'replyTo' => 'info@example.com',
'replyToName' => iconv("UTF-8", "ISO-8859-1", 'Supports öäü'),
'subject' => 'Subject Line',
'template' => 'contact',
'transport' => option('smtp.info')
])
Newsletter Controller
$form->emailAction([
'to' => iconv("UTF-8", "ISO-8859-1", $form->data('email')),
'from' => 'newsletter@example.com',
'fromName' => iconv("UTF-8", "ISO-8859-1", 'Supports öäü'),
'replyTo' => 'newsletter@example.com',
'replyToName' => iconv("UTF-8", "ISO-8859-1", 'Supports öäü'),
'subject' => 'Subject Line',
'template' => 'newsletter',
'transport' => option('smtp.newsletter')
])
Thanks for all the hints and I hope this will help someone else in the future!