Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP]Wysyłka maili, cztery takie same maile
Forum PHP.pl > Forum > Przedszkole
pietroff
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.  
gino
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

pietroff
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
nospor
$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?
pietroff
Ech no tak sad.gif Dzięki za podpowiedź
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.