Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Problem z autoryzacją SMTP w direct admin
projektGraf
post
Post #1





Grupa: Zarejestrowani
Postów: 32
Pomógł: 0
Dołączył: 19.09.2009

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


Witam

Do wysyłania autoryzowanych wiadomości e-mail korzystam z gniazd (socket). Oto kodzik:

  1. // $server_smtp - nazwa serwera smtp
  2. // $login - login
  3. // $pass - hasło
  4. // $sender - nadawca
  5. // $receiver - odbiorca
  6. // $title - tytuł
  7. // $mailHtml - treść wiadomości
  8.  
  9. function sendMailHtml($server_smtp, $login, $pass, $sender, $receiver, $title, $mailHtml) {
  10. global $report;
  11.  
  12. $send = @fsockopen($server_smtp, 587, $errno, $errstr);
  13. $report = fgets($send,1024)."<br />";
  14.  
  15. fputs($send,"HELO $server_smtp\r\n");
  16. $report = fgets($send,1024)."<br />";
  17.  
  18. // autoryzacja SMTP
  19. fputs($send, "AUTH LOGIN\r\n");
  20. $report .= fgets($send,1024)."<br />";
  21.  
  22. fputs($send, base64_encode($login)."\r\n");
  23. fputs($send, base64_encode($pass)."\r\n");
  24. $report .= fgets($send,1024)."<br />";
  25.  
  26. fputs($send, "MAIL FROM: ".$sender."\r\n");
  27. $report .= fgets($send,1024)."<br />";
  28. fputs($send, "RCPT TO: ".$receiver."\r\n");
  29. $report .= fgets($send,1024)."<br />";
  30.  
  31. fputs($send, "DATA\r\n");
  32. fputs($send, "From: ".$sender."\r\n");
  33. fputs($send, "Date: ".date("d").' '.date("M").' '.date("y").' '.date('H:i')."\r\n");
  34. fputs($send, "Subject: ".$title."\r\n");
  35. fputs($send, "To: ".$receiver."\r\n");
  36. fputs($send, "MIME-Version: 1.0\r\n");
  37. fputs($send, "Content-type: text/html; charset=utf-8\r\n");
  38. fputs($send, "Content-Transfer-Encoding: 8bit;\r\n");
  39. fputs($send, "\r\n");
  40. fputs($send, strtr($mailHtml, "\xA5\x8C\x8F\xB9\x9C\x9F", "\xA1\xA6\xAC\xB1\xB6\xBC")."\r\n");
  41. $report .= fgets($send,1024)."<br />";
  42.  
  43. fputs($send, ".\r\n");
  44. fputs($send,"QUIT\r\n");
  45. $report .= fgets($send,1024)."<br />";
  46.  
  47. fclose($send);
  48.  
  49. }
  50.  


Sam skrypt działa z wyjątkiem 2 serwerów. linuxcom.pl i follownet.pl, na obydwuch jest directAdmin. Problem jest taki:
Konfiguruje skrypt na serwer SMTP w kei, wp, onet wiadomość od razu wychodzi.
Konfiguruje skrypt na serwer SMTP linuxcom.pl, follownet.pl wiadomość niby wyszła bo nie ma żadnych błędów, ale gdzieś ginie na serwerze.

Z otrzymanych logów serwera:
MTP protocol synchronization error (next input sent too soon: pipelining was not advertised): rejected "DATA"


2010-03-01 11:48:18 H=s02.follownet.pl (mail.eye.media.pl) [94.23.48.131]
incomplete transaction (sync failure) from <sklep@eye.media.pl>
2010-03-01 11:48:18 SMTP protocol synchronization error (next input sent too soon:
pipelining was not advertised): rejected "DATA" H=s02.follownet.pl
(mail.eye.media.pl) [94.23.48.131] next input="From: Automat systemowy
<sklep@eye.media.pl>\r\nDate: 01 Mar 10 11:48\r\nSubject: Aktywacja nowego
konta.\r\nTo: biuro@isp-media.pl\r\nMIME-Version: 1.0\r\nCont"


Tutaj znalazłem podpowiedź
http://www.exim.org/lurker/message/2005012...a2c15ae.en.html

Czy można prosić o pomoc aby skrypt działał i na tych dwóch serwerach korzystając z kont serwera, a nie zewnętrznych??

Pozdrawiam
I bardzo proszę o pomoc


Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 4)
mls
post
Post #2





Grupa: Zarejestrowani
Postów: 677
Pomógł: 89
Dołączył: 31.08.2003
Skąd: Warszawa

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


Błąd polega na tym, że po wysłaniu polecenia DATA należy jeszcze odebrać odpowiedź z serwera SMTP, a dopiero później można wysłać treść wiadomości...


--------------------
Go to the top of the page
+Quote Post
projektGraf
post
Post #3





Grupa: Zarejestrowani
Postów: 32
Pomógł: 0
Dołączył: 19.09.2009

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


To wiem ale jak to rozwiązać.

Pozdrawiam
Go to the top of the page
+Quote Post
mls
post
Post #4





Grupa: Zarejestrowani
Postów: 677
Pomógł: 89
Dołączył: 31.08.2003
Skąd: Warszawa

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


Acha. Czyli korzystasz z funkcji, której działania ani trochę nie rozumiesz...
  1. fputs($send, "DATA\r\n");
  2. $report .= fgets($send,1024)."<br />";


--------------------
Go to the top of the page
+Quote Post
projektGraf
post
Post #5





Grupa: Zarejestrowani
Postów: 32
Pomógł: 0
Dołączył: 19.09.2009

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


Nad tym problemem siedzę już jakiś czas i się zapętliłem.

Jeśli dobrze cię zrozumiałem to kod powinien wyglądać tak:
  1.  
  2. $send = @fsockopen($server_smtp, 25, $errno, $errstr);
  3. $report = fgets($send,1024)."<br />";
  4.  
  5. fputs($send,"HELO $server_smtp\r\n");
  6. $report = fgets($send,1024)."<br />";
  7.  
  8. // autoryzacja SMTP
  9. fputs($send, "AUTH LOGIN\r\n");
  10. $report .= fgets($send,1024)."<br />";
  11.  
  12. fputs($send, base64_encode($login)."\r\n");
  13. fputs($send, base64_encode($pass)."\r\n");
  14. $report .= fgets($send,1024)."<br />";
  15.  
  16. fputs($send, "MAIL FROM: ".$sender."\r\n");
  17. $report .= fgets($send,1024)."<br />";
  18. fputs($send, "RCPT TO: ".$receiver."\r\n");
  19. $report .= fgets($send,1024)."<br />";
  20.  
  21. fputs($send, "DATA\r\n");
  22. $report .= fgets($send,1024)."<br />";
  23.  
  24. fputs($send, "From: ".$sender."\r\n");
  25. fputs($send, "Date: ".date("d").' '.date("M").' '.date("y").' '.date('H:i')."\r\n");
  26. fputs($send, "Subject: ".$title."\r\n");
  27. fputs($send, "To: ".$receiver."\r\n");
  28. fputs($send, "MIME-Version: 1.0\r\n");
  29. fputs($send, "Content-type: text/html; charset=utf-8\r\n");
  30. fputs($send, "Content-Transfer-Encoding: 8bit;\r\n");
  31. fputs($send, "\r\n");
  32. fputs($send, strtr($mailHtml, "\xA5\x8C\x8F\xB9\x9C\x9F", "\xA1\xA6\xAC\xB1\xB6\xBC")."\r\n");
  33. $report .= fgets($send,1024)."<br />";
  34.  
  35. fputs($send, ".\r\n");
  36. fputs($send,"QUIT\r\n");
  37. $report .= fgets($send,1024)."<br />";
  38.  
  39. fclose($send);
  40.  
  41.  
  42.  


Dobrze Cię zrozumiałem?questionmark.gif Jeśli tak to niestety nie wysyła.
Pozdrawiam
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 Aktualny czas: 20.08.2025 - 14:57