$config = new Configuration();
$config->setApiKey('api-key', $_ENV['SENDINBLUE_KEY']);
$apiInstance = new ContactsApi(
new client(),
$config
);
$apiInstance = new TransactionalEmailsApi(
new Client(),
$config
);
$sendSmtpEmail = new SendSmtpEmail();
$sendSmtpEmail['to'] = array(array('email' => $_POST['email']));
$sendSmtpEmail['templateId'] = 59;
$sendSmtpEmail['params'] = array('texte' => '', 'surname' => 'Doe');
$sendSmtpEmail['headers'] = array('X-Mailin-custom' => 'custom_header_1:custom_value_1|custom_header_2:custom_value_2');
try {
$result = $apiInstance->sendTransacEmail($sendSmtpEmail);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling TransactionalEmailsApi->sendTransacEmail: ', $e->getMessage(), PHP_EOL;
}
//working_directory/emailBuilder.php
require_once(__DIR__ . '/vendor/autoload.php');
$credentials = SendinBlueClientConfiguration::getDefaultConfiguration()->setApiKey('api-key', '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');
$apiInstance = new SendinBlueClientApiTransactionalEmailsApi(new GuzzleHttpClient(),$credentials);
//#######################################//
$sendSmtpEmail = new SendinBlueClientModelSendSmtpEmail([
'subject' => 'Réinitialisation du mot de passe',
'sender' => ['name' => 'Clever Support', 'email' => 'contact@clever.how'],
'replyTo' => ['name' => 'Clever Support', 'email' => 'contact@clever.how'],
'to' => [[ 'name' => 'Support', 'email' => $dn['email']]],
'templateId' => 6,
'params' => ['reset_link' => 'https://clever.how/v3/reset_process.php?email='.$email.'&key='.$key.'']
]);
try {
$result = $apiInstance->sendTransacEmail($sendSmtpEmail);
// print_r($result);
$reponse = 'ok';
} catch (Exception $e) {
// echo '<small>Exception when calling TransactionalEmailsApi->sendTransacEmail: </small>', $e->getMessage(), PHP_EOL;
$reponse = 'Nous avons rencontré un problème. Merci de nous écrire à contact@clever.how';
}