Skip to content

Commit

Permalink
Fix mail send
Browse files Browse the repository at this point in the history
  • Loading branch information
lucatacconi committed May 19, 2023
1 parent 398a812 commit 96cb42a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions routes/api/tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
}

use Symfony\Component\Yaml\Yaml;
use Symfony\Component\Mailer\Transport;
use Symfony\Component\Mailer\Mailer;
use Symfony\Component\Mime\Email;
use Symfony\Component\Mime\Address;

$app->group('/tools', function (RouteCollectorProxy $group) {

Expand Down Expand Up @@ -88,24 +92,26 @@

$from = new Address($crunz_config["mailer"]["sender_email"], $crunz_config["mailer"]["sender_name"]);

unset($messageObject);

$aSENT = [];
foreach ($params["RECIPIENT_LST"] ?? [] as $recipient_name => $recipient_mail) {

unset($messageObject);

$messageObject = (new Email())
->from($from)
->subject($subject)
->text($message)
;

$messageObject->addTo(new Address($recipient_mail, $recipient_name));

$check_mail = $mailer->send($messageObject);

if($mailer->send($messageObject)){
if( $check_mail == null ){
$aSENT[$recipient_name] = 'SENT';
}else{
$aSENT[$recipient_name] = 'ERR';
}
}
}

}else{
Expand Down

0 comments on commit 96cb42a

Please sign in to comment.