Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] ustawienia poczty
bubu77
post
Post #1





Grupa: Zarejestrowani
Postów: 36
Pomógł: 0
Dołączył: 24.11.2008

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


Witam. Męcze się z wysłaniem emaila ze strony php. Cały czas wyskakuje mi, że nie może połączyć się z SMTP. Ściągnąłem klsę PHPmailer i jest to samo tylko nie wiem czy dobrze ustawiłem.
Tak wygląda kod PHP

  1. <?php
  2. IsSMTP(); // send via SMTP
  3. $mail->SMTPAuth = true; // turn on SMTP authentication
  4. $mail->Username = "[email="nazwa@gmail.com"]nazwa@gmail.com[/email]"; // SMTP username
  5. $mail->Password = "hasło"; // SMTP password
  6. $webmaster_email = "[email="nazwa@gmail.com"]nazwa@gmail.com[/email]"; //Reply to this email ID
  7. $email="[email="nazwa@gmail.com"]nazwa@gmail.com[/email]"; // Recipients email ID
  8. $name="name"; // Recipient's name
  9. $mail->From = $webmaster_email;
  10. $mail->FromName = "Webmaster";
  11. $mail->AddAddress($email,$name);
  12. $mail->AddReplyTo($webmaster_email,"Webmaster");
  13. $mail->WordWrap = 50; // set word wrap
  14. $mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment
  15. $mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // attachment
  16. $mail->IsHTML(true); // send as HTML
  17. $mail->Subject = "This is the subject";
  18. $mail->Body = "Hi,
  19. This is the HTML BODY "; //HTML Body
  20. $mail->AltBody = "This is the body when user views in plain text format"; //Text Body
  21. if(!$mail->Send())
  22. {
  23.  echo "Mailer Error: " . $mail->ErrorInfo;
  24. }
  25. else
  26. {
  27.  echo "Message has been sent";
  28. }
  29. ?>

i w class.smtp.php zmieniłem:
$host = "ssl://smtp.gmail.com";
$port = 465;

Co jeszcze trzeba zrobić? Jest to serwer lokalny. Czy ma znaczenie konfiguracja outlooka i czy cos trzeba zmienic w php.ini


Ten post edytował bubu77 4.12.2008, 14:45:40
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
bubu77
post
Post #2





Grupa: Zarejestrowani
Postów: 36
Pomógł: 0
Dołączył: 24.11.2008

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


No i co z tego, że jest napisane jak mi i tak nie działa.

  1. <?php
  2.  
  3. // example on using PHPMailer with GMAIL
  4.  
  5. include("phpmailer/class.phpmailer.php");
  6. include("phpmailer/class.smtp.php"); // note, this is optional - gets called from main class if not already loaded
  7.  
  8. $mail             = new PHPMailer();
  9.  
  10. $body             = $mail->getFile('contents.html');
  11. $body             = eregi_replace("[]",'',$body);
  12.  
  13. $mail->IsSMTP();
  14. $mail->SMTPAuth   = true;                  // enable SMTP authentication
  15. $mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
  16. $mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
  17. $mail->Port       = 465;                   // set the SMTP port
  18.  
  19. $mail->Username   = "[email="nazwa@gmail.com"]nazwa@gmail.com[/email]";  // GMAIL username
  20. $mail->Password   = "Stop2007";            // GMAIL password
  21.  
  22. $mail->From       = "[email="nazwa@gmail.com"]nazwa@gmail.com[/email]";
  23. $mail->FromName   = "Webmaster";
  24. $mail->Subject    = "This is the subject";
  25. $mail->AltBody    = "This is the body when user views in plain text format"; //Text Body
  26. $mail->WordWrap   = 50; // set word wrap
  27.  
  28. $mail->MsgHTML($body);
  29.  
  30. $mail->AddReplyTo("[email="nazwa@gmail.com"]nazwa@gmail.com","Webmaster[/email]");
  31.  
  32. $mail->AddAttachment("PHPMailer/examples/images/phpmailer.gif", "new.jpg"); // attachment
  33.  
  34. $mail->AddAddress("[email="nazwa@gmail.com"]nazwa@gmail.com","First[/email] Last");
  35.  
  36. $mail->IsHTML(true); // send as HTML
  37.  
  38. if(!$mail->Send()) {
  39.  echo "Mailer Error: " . $mail->ErrorInfo;
  40. } else {
  41.  echo "Message has been sent";
  42. }
  43.  
  44. ?>


w php.ini zmieniłem

[mail function]

; For Win32 only.

SMTP = ssl:/smtp.gmail.com

smtp_port = 465

; For Win32 only.

sendmail_from = nazwa@gmail.com

i i w class.smtp.php zmieniłem:
$host = "ssl://smtp.gmail.com";
$port = 465;

i ktoś może mi powiedzieć co mam poprawić.
Mam taki komunikat:

Warning: fopen(contents.html) [function.fopen]: failed to open stream: No such file or directory in E:\SERWER\HTML\phpmailer\class.phpmailer.php on line 1870

Warning
: fsockopen() [
function.fsockopen]: no SSL support in this build in E:\SERWER\HTML\phpmailer\class.smtp.php on line 123

Warning
: fsockopen() [
function.fsockopen]: unable to connect to smtp.gmail.com:465 in E:\SERWER\HTML\phpmailer\class.smtp.php on line 123
Mailer Error: SMTP Error: Could not connect to SMTP host.




Ten post edytował bubu77 5.12.2008, 08:46:34
Go to the top of the page
+Quote Post

Posty w temacie


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: 10.10.2025 - 02:57