Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP]Wysyłka maili, cztery takie same maile
pietroff
post 11.06.2020, 21:53:14
Post #1





Grupa: Zarejestrowani
Postów: 22
Pomógł: 0
Dołączył: 11.03.2013

Ostrzeżenie: (0%)
-----


Witajcie,
mam problem z wysyłką maili. Jak już się uporałem z samą wysyłka to teraz wysyłam do każdego 2 takie same maile sad.gif Poniżej kod. Czy możecie wskazać mi błąd jaki popełniam?

Metoda do wysyłania:

  1.  
  2. function send_mail($email,$message,$subject)
  3. {
  4. require_once('mailer/class.phpmailer.php'); //dodanie klasy phpmailer
  5. require_once('mailer/class.smtp.php'); //dodanie klasy smtp
  6.  
  7. $mail = new PHPMailer(TRUE);
  8.  
  9. try {
  10. /* SMTP parameters. */
  11. // kodowanie
  12. $mail->CharSet = "UTF-8";
  13. // wiadomość html
  14. $mail->IsHTML(true);
  15. /* Tells PHPMailer to use SMTP. */
  16. $mail->isSMTP();
  17. /* SMTP server address. */
  18. $mail->Host = 'poczta.o2.pl';
  19. /* Use SMTP authentication. */
  20. $mail->SMTPAuth = TRUE;
  21. /* Set the encryption system. */
  22. $mail->SMTPSecure = 'tls';
  23. /* SMTP authentication username. */
  24. $mail->Username = 'username';
  25. /* SMTP authentication password. */
  26. $mail->Password = '********';
  27. /* Set the SMTP port. */
  28. $mail->Port = 587;
  29. /* Finally send the mail. */
  30. $mail->setFrom('mail', 'Administrator');
  31. $mail->addAddress($email);
  32. $mail->Subject = $subject;
  33. $mail->Body = $message;
  34. $mail->send();
  35. if(!$mail->Send())
  36. {
  37.  
  38. $_SESSION['info'] = "<div class='alarm'><strong>Ups, coś poszło nie tak!</strong> Wiadomość nie została wysłana. 'Mailer error: ' . $mail->ErrorInfo </div></div>";
  39. }
  40. else
  41. {
  42. $_SESSION['info'] = "<div class='alarm'><strong>Powodzenie!</strong></div>";
  43. }
  44. }
  45. catch (Exception $e)
  46. {
  47. echo $e->errorMessage();
  48. }
  49. catch (Exception $e)
  50. {
  51. echo $e->getMessage();
  52. }
  53. }


Wywołanie funkcji:

  1. if (isset($_POST['mail'])){
  2. $email = 'emaill';
  3. $message = 'Wiadomość';
  4. $subject = 'Temat;
  5. $wyslijMaila->send_mail($email, $message, $subject);
  6.  
  7. }
  8.  
Go to the top of the page
+Quote Post
gino
post 11.06.2020, 22:55:04
Post #2





Grupa: Zarejestrowani
Postów: 319
Pomógł: 52
Dołączył: 18.02.2008

Ostrzeżenie: (0%)
-----


a co to za twór ten 'emaill', bo to nawet format maila nie jest?
  1. if (isset($_POST['mail'])){
  2. $email = 'emaill';

skoro z formularza sprawdzasz $_POST['mail'] to chyba na ten adres poczty chcesz wysłać.

gino

Go to the top of the page
+Quote Post
pietroff
post 12.06.2020, 07:35:25
Post #3





Grupa: Zarejestrowani
Postów: 22
Pomógł: 0
Dołączył: 11.03.2013

Ostrzeżenie: (0%)
-----


No tak to zmieniłem tylko dla posta na forum. Oryginalnie jest mail@o2.pl smile.gif Oczywiście maile są wysyłane tylko problemem jest to, że do każdego dochodzą zdublowane czyli dwa takie same sad.gif

Ten post edytował pietroff 12.06.2020, 08:17:37
Go to the top of the page
+Quote Post
nospor
post 12.06.2020, 09:48:40
Post #4





Grupa: Moderatorzy
Postów: 36 455
Pomógł: 6292
Dołączył: 27.12.2004




$mail->send();
if(!$mail->Send())

Naprawde nie widzisz ze dwa razy wolasz funcke send() a tym samym dwa razy wysylasz maila?

edit:
to tez jest mega
catch (Exception $e)
{
echo $e->errorMessage();
}
catch (Exception $e)
{
echo $e->getMessage();
}

Masz jakis syndrom duplikacji czy jak?


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
pietroff
post 12.06.2020, 10:17:20
Post #5





Grupa: Zarejestrowani
Postów: 22
Pomógł: 0
Dołączył: 11.03.2013

Ostrzeżenie: (0%)
-----


Ech no tak sad.gif Dzięki za podpowiedź
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 25.04.2024 - 18:08