8

Здравствуйте! Обращаюсь к тем, кто смог настроить на локальном сервере отправку почты средствами PHP. Очень необходима ваша помощь.

Использую протокол IMAP(gmail или yandex) и SMPT-сервер sendmail. При отправке постоянно происходит ошибка «Connect timed out.», много всего прочитал, возможно кто-то смог решить данную проблему или может необходимо использовать другой сервер для отправки почты.

Подключены расширения PHP: open_ssl, sockets;

Модуль Apache: ssl_module.

Система Windows 7, сервер WAMP Apache, php 5.

PHP-код:

$to       = [email protected]';
$subject  = 'Testing sendmail.exe';
$message  = 'Hi, you just received an email using sendmail!';
$headers  = 'From: [email protected]' . "\r\n" .
            'MIME-Version: 1.0' . "\r\n" .
            'Content-type: text/html; charset=utf-8';

mail($to, $subject, $message, $headers);

if(mail($to, $subject, $message, $headers))
    echo "Email sent";
else
    echo "Email sending failed";

Файл sendmail.ini (всё необходимое для изменения) :

  • smtp_server=smtp.gmail.ru
  • smtp_port=25
  • smtp_ssl=none
  • default_domain=localhost
  • error_logfile=error.log
  • debug_logfile=debug.log
  • auth_username=my_user_name
  • auth_password=my_user_passw
  • pop3_server=
  • pop3_username=
  • pop3_password=
  • force_sender= [email protected]
  • force_recipient=
  • hostname=gmail.com

Файл php.ini раздел [mail function]

; For Win32 only.
;SMTP = localhost
;smtp_port = 25

; For Win32 only.
;sendmail_from = 
;  -i
sendmail_path = "D:\Server\bin\wamp\sendmail\sendmail.exe -t"
;mail.force_extra_parameters =
mail.add_x_header = On

Файл crach.log:

15.07.08 09:10:31 : Connect timed out.

Файл debug.log:

15.07.08 09:10:21 ** --- MESSAGE BEGIN ---
15.07.08 09:10:21 ** To: [email protected] 
15.07.08 09:10:21 ** Subject: Testing sendmail.exe 
15.07.08 09:10:21 ** X-PHP-Originating-Script: 0:test.php 
15.07.08 09:10:21 ** From: [email protected] 
15.07.08 09:10:21 ** MIME-Version: 1.0 
15.07.08 09:10:21 ** Content-type: text/html; charset=utf-8 
15.07.08 09:10:21 ** 
15.07.08 09:10:21 ** Hi, you just received an email using sendmail! 
15.07.08 09:10:21 ** --- MESSAGE END --- 
15.07.08 09:10:21 ** Connecting to smtp.gamil.com:25  
15.07.08 09:10:31 ** Disconnected.
15.07.08 09:10:31 ** Disconnected.
15.07.08 09:10:31 ** Disconnected.
15.07.08 09:10:31 ** Disconnected.
15.07.08 09:10:31 ** Connect timed out. 

Часть файла crach.txt:

exception class   : EIdConnectTimeout  <p>
exception message : Connect timed out.  <p>

main thread ($2740): <p>
0041fa42 +000e sendmail.exe IdException                   112   +1 EIdException.Toss <p>
0044092e +014e sendmail.exe IdIOHandlerStack              279  +38 DoConnectTimeout <p>
00440b4c +01d8 sendmail.exe IdIOHandlerStack              346  +55 TIdIOHandlerStack.ConnectClient <p>
00444a9f +0063 sendmail.exe IdIOHandlerSocket             335  +13 TIdIOHandlerSocket.Open <p>
0044157d +0235 sendmail.exe IdTCPClient                   318  +53 TIdTCPClientCustom.Connect <p>
00445cc8 +00a4 sendmail.exe IdExplicitTLSClientServerBase 257  +23 TIdExplicitTLSClient.Connect <p>
0045ab7b +0017 sendmail.exe IdSMTP                        373   +2 TIdSMTP.Connect <p>
004b5f14 +1060 sendmail.exe sendmail                      808 +326 initialization
76533378 +0010 kernel32.dll     <p>                                    BaseThreadInitThunk <p>

thread $2570: <p>
774b01a2 +0e ntdll.dll     NtWaitForMultipleObjects <p>
76533378 +10 kernel32.dll  BaseThreadInitThunk <p>
10
  • 15.07.08 09:10:21 ** Connecting to smtp.gamil.com:25 - на самом деле так или результат редактирования? Это имя не резвится в DNS.
    – Outtruder
    8 июл 2015 в 7:04
  • В файле-отчёте так написано 8 июл 2015 в 7:07
  • А в sendmail.ini именно smtp_server=smtp.gmail.ru ?
    – Outtruder
    8 июл 2015 в 7:25
  • опечатка) .com) 8 июл 2015 в 7:54
  • и точно не gamil, как в отладочном дампе? Попробуйте вместо 25 указать порт 587.
    – Outtruder
    8 июл 2015 в 8:26

1 ответ 1

4

Вот работающий, только что проверял.

[sendmail]
smtp_server=smtp.googlemail.com
smtp_port=465
smtp_ssl=auto
error_logfile=log/error.log
debug_logfile=log/debug.log
auth_username=*************@gmail.com
auth_password=*************
pop3_server=
pop3_username=
pop3_password=
force_sender=*************@gmail.com
force_recipient=
hostname=*************@gmail.com
0

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.