PDA

Просмотр полной версии : smtp.gmail.com и windows


Isis
10.04.2008, 16:19
php.ini
; For Win32 only.
;SMTP = localhost
;smtp_port = 25
; For Win32 only.
;sendmail_from = me@example.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = "D:\WebServeR\sendmail\sendmail.exe -t"

ПХП код который отправляет письма:

<?php
function authgMail($from, $namefrom, $to, $nameto, $subject, $message)
{
$smtpServer = "tls://smtp.gmail.com";
$port = "465";
$timeout = "45";
$username = "";
$password = "";
$localhost = $_SERVER['REMOTE_ADDR'];
$newLine = "\r\n";
$smtpConnect = fsockopen($smtpServer, $port, $errno, $errstr, $timeout);
echo $errstr." - ".$errno;
$smtpResponse = fgets($smtpConnect, 4096);
if(empty($smtpConnect))
{
$output = "Failed to connect: $smtpResponse";
echo $output;
return $output;
}
else
{
$logArray['connection'] = "Connected to: $smtpResponse";
echo "connection accepted<br>".$smtpResponse."<p />Continuing<p />";
}
fputs($smtpConnect, "HELO $localhost". $newLine);
$smtpResponse = fgets($smtpConnect, 4096);
$logArray['heloresponse2'] = "$smtpResponse";
fputs($smtpConnect,"AUTH LOGIN" . $newLine);
$smtpResponse = fgets($smtpConnect, 4096);
$logArray['authrequest'] = "$smtpResponse";
fputs($smtpConnect, base64_encode($username) . $newLine);
$smtpResponse = fgets($smtpConnect, 4096);
$logArray['authusername'] = "$smtpResponse";
fputs($smtpConnect, base64_encode($password) . $newLine);
$smtpResponse = fgets($smtpConnect, 4096);
$logArray['authpassword'] = "$smtpResponse";
fputs($smtpConnect, "MAIL FROM: <$from>" . $newLine);
$smtpResponse = fgets($smtpConnect, 4096);
$logArray['mailfromresponse'] = "$smtpResponse";
fputs($smtpConnect, "RCPT TO: <$to>" . $newLine);
$smtpResponse = fgets($smtpConnect, 4096);
$logArray['mailtoresponse'] = "$smtpResponse";
fputs($smtpConnect, "DATA" . $newLine);
$smtpResponse = fgets($smtpConnect, 4096);
$logArray['data1response'] = "$smtpResponse";
//$headers = "MIME-Version: 1.0" . $newLine;
//$headers .= "Content-type: text/html; charset=utf-8" . $newLine;
//$headers = "To: $nameto <$to>" . $newLine;
//$headers .= "From: $namefrom <$from>" . $newLine;
fputs($smtpConnect, "To: $to\r\nFrom: $from\r\nSubject: $subject\r\n$headers\r\n\r\n$message\r\n.\r\n");
$smtpResponse = fgets($smtpConnect, 4096);
$logArray['data2response'] = "$smtpResponse";
fputs($smtpConnect,"QUIT" . $newLine);
$smtpResponse = fgets($smtpConnect, 4096);
$logArray['quitresponse'] = "$smtpResponse";
$logArray['quitcode'] = substr($smtpResponse,0,3);
fclose($smtpConnect);
return($logArray);
}
?>

Вроде sendmail.ini настроил нормально...

Вот что пишет:

Warning: fsockopen() [function.fsockopen]: unable to connect to tls://smtp.gmail.com:465 (Unable to find the socket transport "tls" - did you forget to enable it when you configured PHP?) in functions.php on line 57
Unable to find the socket transport "tls" - did you forget to enable it when you configured PHP? - 5
Warning: fgets(): supplied argument is not a valid stream resource in functions.php on line 59
Failed to connect:

.:EnoT:.
10.04.2008, 17:04
насколько я знаю в винде есть баг, из-за которого не работает sendmail
Обновление есть на офф сайте мелкософта

Isis
10.04.2008, 17:19
Нет..это не причина..
Месяца 3 назад все работало..я что-то сделал и вот не пашет

Хозяин
10.04.2008, 17:35
SMTP server address: ssl://smtp.gmail.com
SMTP server port: 465

ну и раскомментируй OPENSSL.dll в php.ini

Все пашет, сам когда-то прое...ся с отправкой

Isis
12.04.2008, 04:22
ссл включен..все равно ошибка :(

WAR!9G
08.08.2008, 12:43
Всё дело в smtp.gmail.com:465 - толку не будет. Пробуй - smtp.googlemail.com на 578 порт