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
wookieb
post
Post #2





Grupa: Moderatorzy
Postów: 8 989
Pomógł: 1550
Dołączył: 8.08.2008
Skąd: Słupsk/Gdańsk




Człowieku... i inni ludzie. Nauczcie sie CZYTAĆ!
w ściągnietej paczce w folderze docs i pliku "use_gmail.txt" pisze DOKŁADNIE jak korzystać z poczty na gmail
CODE

<?php

// example on using PHPMailer with GMAIL

include("class.phpmailer.php");
include("class.smtp.php"); // note, this is optional - gets called from main class if not already loaded

$mail = new PHPMailer();

$body = $mail->getFile('contents.html');
$body = eregi_replace("[\]",'',$body);

$mail->IsSMTP();
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port

$mail->Username = "yourname@gmail.com"; // GMAIL username
$mail->Password = "password"; // GMAIL password

$mail->From = "replyto@yourdomain.com";
$mail->FromName = "Webmaster";
$mail->Subject = "This is the subject";
$mail->AltBody = "This is the body when user views in plain text format"; //Text Body
$mail->WordWrap = 50; // set word wrap

$mail->MsgHTML($body);

$mail->AddReplyTo("replyto@yourdomain.com","Webmaster");

$mail->AddAttachment("/path/to/file.zip"); // attachment
$mail->AddAttachment("/path/to/image.jpg", "new.jpg"); // attachment

$mail->AddAddress("username@domain.com","First Last");

$mail->IsHTML(true); // send as HTML

if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent";
}

?>



W dodatku co to jest za zapis?
Kod
$email="[email="nazwa@gmail.com"]nazwa@gmail.com[/email]"; // Recipients email ID

Przecież on nie powinien zadziałać

Ten post edytował wookieb 4.12.2008, 15:08:50
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: 4.10.2025 - 19:53