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 2Pobrał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:
<?php
function logger($message){
$message = get_object_vars($message);
endif;
else:
endif;
}
require_once "class.phpmailer.php";
logger('retrieved mailer class');
$mail = new PHPMailer();
logger('instantiated php mailer');
$mail->IsSMTP(); // send via SMTP
$mail->SMTPDebug = 5;
logger('set phpmailer to SMTP');
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "karolol127@gmail.com"; // SMTP username
$mail->Password = "mojeigowamniedam"; // SMTP password
$mail->From = "karolol127@gmail.com";
$mail->FromName = "Webtester";
$mail->AddAddress("luk1287@gmail.com", "Mike");
logger('added address to mail object');
$mail->IsHTML(true); // send as HTML
$mail->Subject = "This is the subject";
$mail->Body = "Hi, This is the HTML BODY "; //HTML Body
$mail->AltBody = "This is the body when user views in plain text format"; //Text Body
logger('about to send message');
try{
$mail->Send();
logger('mail sent successfully over tls');
} catch ( phpmailerException $e ) {
logger("Error sending mail \n" . $e->errormessage());
logger("trying alternative port");
try{
$mail->Port = 465;
$mail->SMTPSecure = 'ssl';
$mail->send();
logger('Mail sent successfully via alternative port');
} catch (phpmailerException $e ){
logger("Error sending mail with alternative port \n" . $e->errorMessage());
} catch (Exception $e) {
logger( $e->getMessage());
}
} catch (Exception $e) {
logger( $e->getMessage());
}
?>
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