Skip to content

Commit 9c3f216

Browse files
authored
Correction du code pour l'envoi de mails (#61)
1 parent 2219afa commit 9c3f216

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

06.01-gestion-et-envoi-des-e-mails/01-supports-de-cours/PRESENTATION.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,11 @@ try {
288288
$mail->Host = $host;
289289
$mail->Port = $port;
290290
$mail->SMTPAuth = $authentication;
291-
$mail->Username = $username;
292-
$mail->Password = $password;
291+
if ($authentication) {
292+
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
293+
$mail->Username = $username;
294+
$mail->Password = $password;
295+
}
293296
$mail->CharSet = "UTF-8";
294297
$mail->Encoding = "base64";
295298
```

06.01-gestion-et-envoi-des-e-mails/01-supports-de-cours/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -640,8 +640,11 @@ try {
640640
$mail->Host = $host;
641641
$mail->Port = $port;
642642
$mail->SMTPAuth = $authentication;
643-
$mail->Username = $username;
644-
$mail->Password = $password;
643+
if ($authentication) {
644+
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
645+
$mail->Username = $username;
646+
$mail->Password = $password;
647+
}
645648
$mail->CharSet = "UTF-8";
646649
$mail->Encoding = "base64";
647650

06.01-gestion-et-envoi-des-e-mails/02-exemples-de-code/01-envoi-de-mail/public/index.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@
2828
$mail->Host = $host;
2929
$mail->Port = $port;
3030
$mail->SMTPAuth = $authentication;
31-
$mail->Username = $username;
32-
$mail->Password = $password;
31+
if ($authentication) {
32+
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
33+
$mail->Username = $username;
34+
$mail->Password = $password;
35+
}
3336
$mail->CharSet = "UTF-8";
3437
$mail->Encoding = "base64";
3538

06.01-gestion-et-envoi-des-e-mails/03-exercices/solution-exercice-01/public/index.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@
4343
$mail->Host = $host;
4444
$mail->Port = $port;
4545
$mail->SMTPAuth = $authentication;
46-
$mail->Username = $username;
47-
$mail->Password = $password;
46+
if ($authentication) {
47+
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
48+
$mail->Username = $username;
49+
$mail->Password = $password;
50+
}
4851
$mail->CharSet = "UTF-8";
4952
$mail->Encoding = "base64";
5053

0 commit comments

Comments
 (0)