I am using laravel 5.3. I need to send mail with different credentials (host, port, username, password).
I can send the default laravel config (.env).
But I need a dynamic level implementation.
I create a config array,
$store_config = [
'list' =>
['from_name' => 'sender1',
'from_address' => 'from_adderss1',
'return_address' => 'reply1',
'subject' => 'subject1',
'host' => 'host1',
'port' => 'post1',
'authentication' => 'auth1',
'username' => 'uname1',
'password' => 'pass1'],
[.........],
[.........]
];
I am trying to send a message, but this will not work.
$transporter = \Swift_MailTransport::newInstance('smtp.gmail.com', 465, 'ssl')
->setUsername($config['username'])
->setPassword($config['password']);
$mailer = \Swift_Mailer::newInstance($transporter);
$message->from($config['from_address'], $config['from_name']);
$message->to('To_Email, 'Name')
->subject('My Subject')
->setBody('My Content', 'text/html');
$mailer->send($message);
What is wrong with my code?
Is it possible?
Or any other solution?
source
share