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%)
-----


Dobra zmieniłem SMTP na takie jak podałeś i wygląda to tak
php.ini
mail function]
; For Win32 only.
SMTP = smtp.gmail.com
smtp_port = 25

; For Win32 only.
sendmail_from = karolol127@gmail.com

Skrypt daje wynik

Warning: mail() [function.mail]: SMTP server response: 530 5.7.0 Must issue a STARTTLS command first. n3sm51539983wiz.9 in C:\Program Files (x86)\WebServ\httpd\testscrypt.php on line 2


Pobrałem PHPMailer ze strony podanej wyżej (http://phpmailer.worxware.com/) i chce go zainstalować pomoże ktoś ? Mam niby wkleić gdzieś 1 plik ale nie rozumiem czy do folderu czy to jakiegoś pliku. "Installation:

Copy class.phpmailer.php into your php.ini include_path. If you are
using the SMTP mailer then place class.smtp.php in your path as well.
"

Szukam cały dzień i trafiłem na podobny problem u jakiegoś gościa. Pobrałem PHPMailer v5.1
(http://sourceforge.net/projects/phpmailer/files/phpmailer%20for%20php5_6/PHPMailer%20v5.1/).
Skopiowałem plik class.phpmailer.php do folderu w którym mam pliki php testowane na localhoscie.
Kod skryptu wysyłającego maila wygląda następująco:
  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. $mail->Host = 'smtp.gmail.com';
  28. $mail->Port = 587;
  29. $mail->SMTPSecure = 'tls';
  30.  
  31. $mail->SMTPAuth = true; // turn on SMTP authentication
  32. $mail->Username = "karolol127@gmail.com"; // SMTP username
  33. $mail->Password = "mojeigowamniedam"; // SMTP password
  34.  
  35. $mail->From = "karolol127@gmail.com";
  36. $mail->FromName = "Webtester";
  37. $mail->AddAddress("luk1287@gmail.com", "Mike");
  38. logger('added address to mail object');
  39.  
  40. $mail->IsHTML(true); // send as HTML
  41. $mail->Subject = "This is the subject";
  42. $mail->Body = "Hi, This is the HTML BODY "; //HTML Body
  43. $mail->AltBody = "This is the body when user views in plain text format"; //Text Body
  44.  
  45.  
  46. logger('about to send message');
  47.  
  48. try{
  49.  
  50. $mail->Send();
  51. logger('mail sent successfully over tls');
  52.  
  53. } catch ( phpmailerException $e ) {
  54.  
  55. logger("Error sending mail \n" . $e->errormessage());
  56. logger("trying alternative port");
  57.  
  58. try{
  59. $mail->Port = 465;
  60. $mail->SMTPSecure = 'ssl';
  61. $mail->send();
  62. logger('Mail sent successfully via alternative port');
  63.  
  64. } catch (phpmailerException $e ){
  65. logger("Error sending mail with alternative port \n" . $e->errorMessage());
  66. } catch (Exception $e) {
  67. logger( $e->getMessage());
  68. }
  69. } catch (Exception $e) {
  70. logger( $e->getMessage());
  71. }
  72. ?>


Plik php.ini wygląda tak:

[mail function]
; For Win32 only.
SMTP = smtp.gmail.com
smtp_port = 587

; For Win32 only.
sendmail_from = karolol127@gmail.com

; Windows: "\path1;\path2"
;include_path = ".;C:/Program Files (x86)/WebServ/includes"
// tam też wrzuciłem plik class.phpmailer.php

Błędy które są(mam nadzieje że ich urozmaicenie pomoże znleśc problem komuś kto się na tym zna):
retrieved mailer class

instantiated php mailer

set phpmailer to SMTP

added address to mail object

about to send message

SMTP -> get_lines(): $data was ""

SMTP -> get_lines(): $str is "220 mx.google.com ESMTP y54sm74216878eef.8
"

SMTP -> get_lines(): $data is "220 mx.google.com ESMTP y54sm74216878eef.8
"

SMTP -> FROM SERVER:220 mx.google.com ESMTP y54sm74216878eef.8


SMTP -> get_lines(): $data was ""

SMTP -> get_lines(): $str is "250-mx.google.com at your service, [94.240.10.192]
"

SMTP -> get_lines(): $data is "250-mx.google.com at your service, [94.240.10.192]
"

SMTP -> get_lines(): $data was "250-mx.google.com at your service, [94.240.10.192]
"

SMTP -> get_lines(): $str is "250-SIZE 35882577
"

SMTP -> get_lines(): $data is "250-mx.google.com at your service, [94.240.10.192]
250-SIZE 35882577
"

SMTP -> get_lines(): $data was "250-mx.google.com at your service, [94.240.10.192]
250-SIZE 35882577
"

SMTP -> get_lines(): $str is "250-8BITMIME
"

SMTP -> get_lines(): $data is "250-mx.google.com at your service, [94.240.10.192]
250-SIZE 35882577
250-8BITMIME
"

SMTP -> get_lines(): $data was "250-mx.google.com at your service, [94.240.10.192]
250-SIZE 35882577
250-8BITMIME
"

SMTP -> get_lines(): $str is "250-STARTTLS
"

SMTP -> get_lines(): $data is "250-mx.google.com at your service, [94.240.10.192]
250-SIZE 35882577
250-8BITMIME
250-STARTTLS
"

SMTP -> get_lines(): $data was "250-mx.google.com at your service, [94.240.10.192]
250-SIZE 35882577
250-8BITMIME
250-STARTTLS
"

SMTP -> get_lines(): $str is "250 ENHANCEDSTATUSCODES
"

SMTP -> get_lines(): $data is "250-mx.google.com at your service, [94.240.10.192]
250-SIZE 35882577
250-8BITMIME
250-STARTTLS
250 ENHANCEDSTATUSCODES
"

SMTP -> FROM SERVER: 250-mx.google.com at your service, [94.240.10.192]
250-SIZE 35882577
250-8BITMIME
250-STARTTLS
250 ENHANCEDSTATUSCODES


SMTP -> get_lines(): $data was ""

SMTP -> get_lines(): $str is "220 2.0.0 Ready to start TLS
"

SMTP -> get_lines(): $data is "220 2.0.0 Ready to start TLS
"

SMTP -> FROM SERVER:220 2.0.0 Ready to start TLS




Warning: stream_socket_enable_crypto() [streams.crypto]: this stream does not support SSL/crypto in C:\Program Files (x86)\WebServ\httpd\class.smtp.php on line 197



Ten post edytował karolius 30.01.2012, 16:23:15
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: 3.10.2025 - 03:02