diff options
author | polo <ordipolo@gmx.fr> | 2025-09-12 17:12:04 +0200 |
---|---|---|
committer | polo <ordipolo@gmx.fr> | 2025-09-12 17:12:04 +0200 |
commit | 07819d9f9e151e9fed6a6490dcad53ba2d57a550 (patch) | |
tree | a1c66b57921fc17ae7a96e3c016121afc6d7e7f7 | |
parent | de6a28c63d18a72baa044d9385ed3d15afb40ef0 (diff) | |
download | cms-07819d9f9e151e9fed6a6490dcad53ba2d57a550.zip |
correction erreur champs vides dans config.ini section [email]
-rw-r--r-- | src/Config.php | 6 | ||||
-rw-r--r-- | src/EmailService.php | 8 | ||||
-rw-r--r-- | src/view/templates/form_params.php | 14 |
3 files changed, 16 insertions, 12 deletions
diff --git a/src/Config.php b/src/Config.php index e25c180..baf4d6d 100644 --- a/src/Config.php +++ b/src/Config.php | |||
@@ -22,10 +22,10 @@ class Config | |||
22 | static public string $smtp_host = ''; | 22 | static public string $smtp_host = ''; |
23 | static public string $smtp_username = ''; | 23 | static public string $smtp_username = ''; |
24 | static public string $smtp_password = ''; | 24 | static public string $smtp_password = ''; |
25 | static public string $smtp_secure = 'tls'; // tls (smarttls) ou ssl (smtps) | 25 | static public string $smtp_secure = ''; // tls (smarttls) ou ssl (smtps) ou plain_text/chaine vide |
26 | static public string $email_from = ''; | 26 | static public string $email_from = 'mon_adresse@email.fr'; |
27 | static public string $email_from_name = 'site web'; | 27 | static public string $email_from_name = 'site web'; |
28 | static public string $email_dest = ''; | 28 | static public string $email_dest = 'mon_adresse@email.fr'; |
29 | static public string $email_dest_name = 'destinataire formulaire'; | 29 | static public string $email_dest_name = 'destinataire formulaire'; |
30 | 30 | ||
31 | // copier dans ce tableau les variables contenant des chemins | 31 | // copier dans ce tableau les variables contenant des chemins |
diff --git a/src/EmailService.php b/src/EmailService.php index a9abc85..1bcca0f 100644 --- a/src/EmailService.php +++ b/src/EmailService.php | |||
@@ -20,7 +20,10 @@ class EmailService | |||
20 | $smtp_secure = $form_data->getData()['smtp_secure'] ?? Config::$smtp_secure; | 20 | $smtp_secure = $form_data->getData()['smtp_secure'] ?? Config::$smtp_secure; |
21 | $smtp_username = $form_data->getData()['smtp_username'] ?? Config::$smtp_username; | 21 | $smtp_username = $form_data->getData()['smtp_username'] ?? Config::$smtp_username; |
22 | $smtp_password = $form_data->getData()['smtp_password'] ?? Config::$smtp_password; | 22 | $smtp_password = $form_data->getData()['smtp_password'] ?? Config::$smtp_password; |
23 | $email_from = $form_data->getData()['email_from'] ?? Config::$email_from; // une adresse bidon est donnée à setFrom() | ||
24 | $email_from_name = $form_data->getData()['email_from_name'] ?? Config::$email_from_name; // = site web | ||
23 | $email_dest = $form_data->getData()['email_dest'] ?? Config::$email_dest; | 25 | $email_dest = $form_data->getData()['email_dest'] ?? Config::$email_dest; |
26 | $email_dest_name = $form_data->getData()['email_dest_name'] ?? Config::$email_dest_name; // = destinataire formulaire | ||
24 | 27 | ||
25 | try{ | 28 | try{ |
26 | // Paramètres du serveur | 29 | // Paramètres du serveur |
@@ -43,8 +46,9 @@ class EmailService | |||
43 | //var_dump($mail->smtpConnect());die; // test de connexion | 46 | //var_dump($mail->smtpConnect());die; // test de connexion |
44 | 47 | ||
45 | // Expéditeur et destinataire | 48 | // Expéditeur et destinataire |
46 | $mail->setFrom(strtolower(Config::$email_from), Config::$email_from_name); // paramètre modifiable uniquement dans le config.ini pour l'instant | 49 | // $email_from, $email_from_name et $email_dest_name sont modifiables uniquement dans le config.ini pour l'instant |
47 | $mail->addAddress(strtolower($email_dest), Config::$email_dest_name); // // paramètre modifiable uniquement dans le config.ini pour l'instant | 50 | $mail->setFrom(strtolower($email_from), $email_from_name); |
51 | $mail->addAddress(strtolower($email_dest), $email_dest_name); | ||
48 | 52 | ||
49 | // Contenu | 53 | // Contenu |
50 | $mail->isHTML(true); | 54 | $mail->isHTML(true); |
diff --git a/src/view/templates/form_params.php b/src/view/templates/form_params.php index a7bf1d8..3559d25 100644 --- a/src/view/templates/form_params.php +++ b/src/view/templates/form_params.php | |||
@@ -22,24 +22,19 @@ declare(strict_types=1); | |||
22 | </p> | 22 | </p> |
23 | <p> | 23 | <p> |
24 | <label for="smtp_username_<?= $node->getNodeData()->getId() ?>">Identifiant (adresse e-mail)</label> | 24 | <label for="smtp_username_<?= $node->getNodeData()->getId() ?>">Identifiant (adresse e-mail)</label> |
25 | <input id="smtp_username_<?= $node->getNodeData()->getId() ?>" type="email" name="smtp_username" placeholder="mon-adresse@email.fr" value="<?= htmlspecialchars($smtp_username) ?>"> | 25 | <input id="smtp_username_<?= $node->getNodeData()->getId() ?>" type="email" name="smtp_username" autocomplete="new-password" placeholder="mon-adresse@email.fr" value="<?= htmlspecialchars($smtp_username) ?>"> |
26 | <input type="hidden" id="smtp_username_hidden_<?= $node->getNodeData()->getId() ?>" value=""> | 26 | <input type="hidden" id="smtp_username_hidden_<?= $node->getNodeData()->getId() ?>" value=""> |
27 | <button onclick="setEmailParam('smtp_username', <?= $node->getNodeData()->getId() ?>)">Valider</button> | 27 | <button onclick="setEmailParam('smtp_username', <?= $node->getNodeData()->getId() ?>)">Valider</button> |
28 | </p> | 28 | </p> |
29 | <p> | 29 | <p> |
30 | <label for="smtp_password_<?= $node->getNodeData()->getId() ?>">Mot de passe</label> | 30 | <label for="smtp_password_<?= $node->getNodeData()->getId() ?>">Mot de passe</label> |
31 | <input id="smtp_password_<?= $node->getNodeData()->getId() ?>" type="password" name="smtp_password"> | 31 | <input id="smtp_password_<?= $node->getNodeData()->getId() ?>" type="password" name="smtp_password" autocomplete="new-password"> |
32 | <input type="hidden" id="smtp_password_hidden_<?= $node->getNodeData()->getId() ?>" value=""> | 32 | <input type="hidden" id="smtp_password_hidden_<?= $node->getNodeData()->getId() ?>" value=""> |
33 | <button onclick="setEmailParam('smtp_password', <?= $node->getNodeData()->getId() ?>)">Valider</button> | 33 | <button onclick="setEmailParam('smtp_password', <?= $node->getNodeData()->getId() ?>)">Valider</button> |
34 | </p> | 34 | </p> |
35 | <p><i>Il s'agit du service qui acheminera les messages envoyés par ce formulaire. Les services d'envoi de courriels nécéssitent généralement de s'y connecter avec un identifiant et un mot de passe. Les adresses d'envoi et de réception peuvent être identiques. Le site web peut ne pas réussir à se connecter à certains fournisseurs.</i></p> | 35 | <p><i>Il s'agit du service qui acheminera les messages envoyés par ce formulaire. Les services d'envoi de courriels nécéssitent généralement de s'y connecter avec un identifiant et un mot de passe. Les adresses d'envoi et de réception peuvent être identiques. Le site web peut ne pas réussir à se connecter à certains fournisseurs.</i></p> |
36 | </div> | 36 | </div> |
37 | <div class="admin_form"> | 37 | <div class="admin_form"> |
38 | <p><button onclick="sendTestEmail(<?= $node->getNodeData()->getId() ?>)">Envoi d'un e-mail de test</button></p> | ||
39 | <p><i>Vérifie la connexion au serveur d'envoi. Pour tester la réception, consultez vos e-mails à l'adresse de réception.</i></p> | ||
40 | <p class="test_email_success_<?= $node->getNodeData()->getId() ?> full_width_column"></p> | ||
41 | </div> | ||
42 | <div class="admin_form"> | ||
43 | <h3>Paramètres de réception</h3> | 38 | <h3>Paramètres de réception</h3> |
44 | <p> | 39 | <p> |
45 | <label for="email_dest_<?= $node->getNodeData()->getId() ?>">Adresse e-mail</label> | 40 | <label for="email_dest_<?= $node->getNodeData()->getId() ?>">Adresse e-mail</label> |
@@ -47,4 +42,9 @@ declare(strict_types=1); | |||
47 | <input type="hidden" id="email_dest_hidden_<?= $node->getNodeData()->getId() ?>" value=""> | 42 | <input type="hidden" id="email_dest_hidden_<?= $node->getNodeData()->getId() ?>" value=""> |
48 | <button onclick="setEmailParam('email_dest', <?= $node->getNodeData()->getId() ?>)">Valider</button> | 43 | <button onclick="setEmailParam('email_dest', <?= $node->getNodeData()->getId() ?>)">Valider</button> |
49 | </p> | 44 | </p> |
45 | </div> | ||
46 | <div class="admin_form"> | ||
47 | <p><button onclick="sendTestEmail(<?= $node->getNodeData()->getId() ?>)">Envoi d'un e-mail de test</button></p> | ||
48 | <p><i>Vérifie la connexion au serveur d'envoi. Pour tester la réception, consultez vos e-mails à l'adresse de réception.</i></p> | ||
49 | <p class="test_email_success_<?= $node->getNodeData()->getId() ?> full_width_column"></p> | ||
50 | </div> \ No newline at end of file | 50 | </div> \ No newline at end of file |