setApiKey('api-key', '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'); $apiInstance = new TransactionalEmailsApi(new GuzzleHttp\Client(), $config); function send_email_with_brevo($to, $from, $subject, $message, $opt) { global $apiInstance; // Create a new SendSmtpEmail object $send_smtp_email = new SendSmtpEmail([ 'to' => $to, 'sender' => ['email' => 'crm@k-ep.hu', 'name' => 'K-ep Studio'], 'cc' => [['email' => 'crm@k-ep.hu', 'name' => 'K-ep Studio']], 'subject' => $subject, 'htmlContent' => $message ]); if(!empty($opt)) $send_smtp_email['params'] = $opt; if(!empty($opt["templateid"])) $send_smtp_email['templateId'] = $opt["templateid"]; else $send_smtp_email['templateId']=41; // add the options try { // Send the email using Brevo's TransactionalEmailsApi $response = $apiInstance->sendTransacEmail($send_smtp_email); // Log response or handle errors if needed //error_log("Email sent successfully."); } catch (Exception $e) { // Log the error // error_log("Error sending email: " . $e->getMessage()); } } $templateStatus = 'true'; // bool | Filter on the status of the template. Active = true, inactive = false $limit = 50; // int | Number of documents returned per page $offset = 0; // int | Index of the first document in the page $sort = "desc"; // string | Sort the results in the ascending/descending order of record creation. Default order is **descending** if `sort` is not passed try { $result = $apiInstance->getSmtpTemplates($templateStatus, $limit, $offset, $sort); } catch (Exception $e) { echo 'Exception when calling TransactionalEmailsApi->getSmtpTemplates: ', $e->getMessage(), PHP_EOL; } $template_arr=array(); $res=(array) $result; foreach($res as $key => $rows){ $r1= (array) $rows['templates']; foreach($r1 as $row){ $r2=(array) $row; foreach($r2 as $r3){ if($r3['isActive']==1) $template_arr[$r3['name']]=$r3['id']; } } } // Main logic for processing form submission or other actions if ($_POST["kod"] == '12345678987654321asdfghjklkjhgfdsa') { // Log the POST data //error_log("POST11: " . json_encode($_POST)); // Add your business logic here // Example: send an email using Brevo //Prepare $_POSZ if (isset($_POST["to"])) $email[0]['email'] = $_POST["to"]; else die(); if (isset($_POST["to_name"])) $email[0]['name'] = $_POST["to_name"]; else $email[0]['name']= $_POST["to"]; if (isset($_POST["from"])) $from=$_POST["from"]; else $from ="k-ep@k-ep.hu"; if (isset($_POST["subjects"])) $subject=$_POST["subjects"]; else $subject="K-ép Studio információs mail"; if (isset($_POST["uzenet"])) $uzenet="
".$_POST["uzenet"].""; elseif (isset($_POST["szoveg"])) $uzenet="" .$_POST["szoveg"]."
"; else $uzenet="