Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [inne][PHP]Problem z funkcją mail
karolius
post
Post #1





Grupa: Zarejestrowani
Postów: 10
Pomógł: 0
Dołączył: 28.01.2012

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


Witam, mam problem z funkcą mail przy odczytywaniu kodu wyskakuje błąd "Warning: mail() [function.mail]: SMTP server response: 550 FQDN required in the envelope recipient in C:\Program Files (x86)\WebServ\httpd\testscrypt.php on line 2" macie coś godnego polecenia do prostego testowania funkcji związanych z wysyłaniem/ odbieraniem maili ? Do tej pory wszystko sprawdzałem na localhoscie przy użyciu Webserva, mam win 7 64 bitowy. Za pomoc z góry dzięki.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
karolius
post
Post #2





Grupa: Zarejestrowani
Postów: 10
Pomógł: 0
Dołączył: 28.01.2012

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


Zmieniłem tak jak kazałeś port i ten skrypt. Informacja wygląda tak:
retrieved mailer class

instantiated php mailer

set phpmailer to SMTP

added address to mail object

about to send message

SMTP -> ERROR: Failed to connect to server: Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP? (199000920)

SMTP Error: Could not connect to SMTP host.

mail sent successfully over tls


Mógłbyś wyjaśnić dlaczego port 465 ,a nie 587 ponoć to ten 2 jest stosowany i od czego jest linijka
  1. $mail->Mailer = "smtp";
, i co tym razem poknociłem.

Dla pewności dodam aktualny skrypt.
  1. <?php
  2. ini_set('display_errors', true);
  3.  
  4. function logger($message){
  5. echo '<pre>';
  6. if(is_object($message)):
  7. $message = get_object_vars($message);
  8. endif;
  9. if(is_array($message)):
  10. print_r($message);
  11. else:
  12. echo $message;
  13. endif;
  14. echo '<pre>';
  15. }
  16.  
  17. require_once "class.phpmailer.php";
  18. logger('retrieved mailer class');
  19.  
  20. $mail = new PHPMailer();
  21. logger('instantiated php mailer');
  22.  
  23. $mail->IsSMTP(); // send via SMTP
  24. $mail->SMTPDebug = 5;
  25. logger('set phpmailer to SMTP');
  26.  
  27.  
  28.  
  29.  
  30. $mail->Host = 'smtp.gmail.com';
  31. $mail->Port = 465;
  32. $mail->SMTPSecure = "ssl";
  33. $mail->Mailer = "smtp";
  34.  
  35.  
  36. $mail->SMTPAuth = true; // turn on SMTP authentication
  37. $mail->Username = "karolol127@gmail.com"; // SMTP username
  38. $mail->Password = "moje"; // SMTP password
  39.  
  40. $mail->From = "karolol127@gmail.com";
  41. $mail->FromName = "Webtester";
  42. $mail->AddAddress("luk12871287@gmail.com", "taktak");
  43. logger('added address to mail object');
  44.  
  45. $mail->IsHTML(true); // send as HTML
  46. $mail->Subject = "This is the subject";
  47. $mail->Body = "Hi, This is the HTML BODY "; //HTML Body
  48. $mail->AltBody = "This is the body when user views in plain text format"; //Text Body
  49.  
  50.  
  51. logger('about to send message');
  52.  
  53. try{
  54.  
  55. $mail->Send();
  56. logger('mail sent successfully over tls');
  57.  
  58. } catch ( phpmailerException $e ) {
  59.  
  60. logger("Error sending mail \n" . $e->errormessage());
  61. logger("trying alternative port");
  62.  
  63. try{
  64. $mail->Port = 465;
  65. $mail->SMTPSecure = 'ssl';
  66. $mail->send();
  67. logger('Mail sent successfully via alternative port');
  68.  
  69. } catch (phpmailerException $e ){
  70. logger("Error sending mail with alternative port \n" . $e->errorMessage());
  71. } catch (Exception $e) {
  72. logger( $e->getMessage());
  73. }
  74. } catch (Exception $e) {
  75. logger( $e->getMessage());
  76. }
  77. ?>


Ten post edytował karolius 30.01.2012, 19:01:20
Go to the top of the page
+Quote Post

Posty w temacie
- karolius   [inne][PHP]Problem z funkcją mail   28.01.2012, 15:00:59
- - Lombi   Z moich skromnych doświadczeń wynika że funkcja ma...   28.01.2012, 15:08:19
- - karolius   Więc co polecacie ? Szkoda mi troche kasy na hosti...   28.01.2012, 15:39:20
- - Necsord   1) Ustawiłeś SMTP ? 2) Do kogo wysyłasz / jakie ma...   28.01.2012, 15:46:10
- - karolius   [PHP] pobierz, plaintext <?phpif(mail...   28.01.2012, 16:18:46
- - cykcykacz   http://phpmailer.worxware.com/   28.01.2012, 16:20:52
- - Necsord   http://pl.wikipedia.org/wiki/Fully_Qualified_Domai...   28.01.2012, 16:22:26
- - karolius   Więc tak skrypt wygląda następująco [PHP] pobierz,...   29.01.2012, 22:24:41
- - Necsord   CytatGmail SMTP server address: smtp.gmail.com Gma...   29.01.2012, 22:51:10
- - karolius   Dobra zmieniłem SMTP na takie jak podałeś i wygląd...   30.01.2012, 17:23:39
- - potreb   Jeżeli chodzi o gmail to takie ustawienia: [PHP] ...   30.01.2012, 18:30:09
- - karolius   Zmieniłem tak jak kazałeś port i ten skrypt. Infor...   30.01.2012, 18:50:22
- - potreb   Mój cały kod wygląd tak, podstaw swoje dane i zoba...   30.01.2012, 21:34:57
- - karolius   wynik Fatal error: Class 'phpmailer' not f...   31.01.2012, 13:42:23
- - Necsord   Cough. [PHP] pobierz, plaintext require_once ...   31.01.2012, 15:38:37
- - karolius   Próbowałem już. Dodałem na początku: [PHP] pobierz...   31.01.2012, 15:51:54
- - Necsord   [PHP] pobierz, plaintext $mail->user_name = cry...   31.01.2012, 16:11:23
- - karolius   Więc co mam zrobić ? Z PHP dopiero zaczynam więc w...   31.01.2012, 16:46:28
- - Necsord   Wpisać na czysto login i hasło pomijając crypt...   31.01.2012, 17:39:58
- - karolius   Więc jak wygląda poprawny kod bez tego Ja na klas...   1.02.2012, 01:48:27


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

 



RSS Aktualny czas: 8.10.2025 - 03:03