Before Laravel switched to Symfony Mailer I was able to check custom SMTP server response the following way:
try {
$transport = new Swift_SmtpTransport($request->smtp_server, $request->smtp_port, $request->secure_connection);
$transport->setUsername($request->smtp_username);
$transport->setPassword($request->smtp_password);
$mailer = new Swift_Mailer($transport);
$mailer->getTransport()->start();
return array(
'success' => true,
'statusCode' => 200,
'message' => 'Success.'
);
} catch (Swift_TransportException $e) {
return response()->json([
'success' => false,
'message' => $e->getMessage(),
], 500);
} catch (Exception $e) {
return response()->json([
'success' => false,
'message' => $e->getMessage(),
], 500);
}
I am currently struggling to figure out how exactly to set the DSN(apparently this is the way to go) configuration and execute a transport connection test. I have been searching around for some documentation but was unable to find anything specific.