PHP Sendmail Failed в windows xampp

Опитвам се да изпращам имейл в Windows чрез моя gmail акаунт, конфигурирах своя php.ini:

SMTP=smtp.gmail.com
smtp_port=587
[email protected]
sendmail_path="\"C:\xampp\sendmail\sendmail.exe\" -t"

and sendmail.ini :
smtp_server=smtp.gmail.com
smtp_port=587
smtp_ssl=auto
error_logfile=error.log
[email protected]
auth_password=my-password-confident
[email protected]

ето моят код:

<?php
// The message
$message = "Line 1\r\nLine 2\r\nLine 3";

// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70, "\r\n");

// Send
$send = mail('[email protected]', 'My Subject', $message);
if ($send) {
    echo "send";
}
else {
echo "fail";}
?>

също така промених сигурността си в Google, стана по-малко сигурна. Нямам представа защо, някой да ми помогне?


person Jais Anasrulloh Ja'fari    schedule 15.02.2015    source източник
comment
Не избягвате обратните наклонени черти в sendmail_path. Това не ми изглежда правилно.   -  person Nathan Tuggy    schedule 16.02.2015
comment
все още е неуспешно, промених го на sendmail_path=\C:\\xampp\\sendmail\\sendmail.exe\ -t   -  person Jais Anasrulloh Ja'fari    schedule 16.02.2015
comment
Чудя се дали локалният сървър може да взаимодейства с онлайн сървъра. ново за мен   -  person Joe Kdw    schedule 16.02.2015
comment
не познавам Jean Gkol, но изглежда, че работи за някои хора stackoverflow.com/questions/15965376/   -  person Jais Anasrulloh Ja'fari    schedule 16.02.2015
comment
През повечето време не можете да изпращате поща от локалния сървър, трябва да качите файла на жив сървър.   -  person Junius L.    schedule 16.02.2015
comment
Опитайте това -› stackoverflow.com/questions/21337859/sendmail-wamp-php. Какви прозорци използвате?   -  person Foxhoundn    schedule 18.02.2015
comment
Възможен дубликат на sendmail.exe се отваря при изпращане на имейл   -  person Pascal    schedule 14.01.2016


Отговори (2)


Не съм сигурен дали използвате Windows 8, но ако използвате, трябва да направите следното -

1 ) В PHP.ini направете частта за имейл да изглежда така

; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
SMTP = localhost
smtp_port = 465

; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = 

; XAMPP IMPORTANT NOTE (1): If XAMPP is installed in a base directory with spaces (e.g. c:\program filesC:\xampp) fakemail and mailtodisk do not work correctly.
; XAMPP IMPORTANT NOTE (2): In this case please copy the sendmail or mailtodisk folder in your root folder (e.g. C:\sendmail) and use this for sendmail_path.  
; XAMPP: Comment out this if you want to work with fakemail for forwarding to your mailbox (sendmail.exe in the sendmail folder)
sendmail_path = "C:\xampp\sendmail\sendmail.exe -t"

; XAMPP: Comment out this if you want to work with mailToDisk, It writes all mails in the C:\xampp\mailoutput folder
;sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe"

; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =

; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header=on

2 ) Направете smtp частта sendmail.ini да изглежда така

smtp_server=localhost

; smtp port (normally 25)

smtp_port=25

; SMTPS (SSL) support
;   auto = use SSL for port 465, otherwise try to use TLS
;   ssl  = alway use SSL
;   tls  = always use TLS
;   none = never try to use SSL

smtp_ssl=none

; if your smtp server requires authentication, modify the following two lines

[email protected]
auth_password=password

3 ) Изтеглете Stunnel https://www.stunnel.org/downloads.html и направете следното промени в stunnel.conf. Stunnel работи в трея, всеки път, когато правите промени, щракнете с десния бутон върху иконата Stunnel и презаредете conf файла.

cert = stunnel.pem
socket = l:TCP_NODELAY=1
socket = r:TCP_NODELAY=1
key = stunnel.pem
[ssmtp]
accept  = 465
connect = 25
[gmail-smtp]
client = yes
accept = 127.0.0.1:25
connect = smtp.gmail.com:465
; To check logs you can enable logging using following lines
debug = 7

4 ) Отидете във вашата папка Sendmail, щракнете с десния бутон върху sendmail.exe -> Свойства -> Съвместимост -> Щракнете върху бутона Направете промени за всички потребители -> Изберете съвместимост с Windows XP (Service Pack 3) и отметнете Изпълни като администратор.

5) Винаги стартирайте XAMPP като администратор!!

Това е необходимо само на Windows 8+ (fex. на Windows 2008 R2 трябваше само да насоча правилно sendmail към gmail и всичко работеше).

person Foxhoundn    schedule 18.02.2015
comment
Изберете Windows XP (Service Pack 3) е правилният отговор за всички проблеми със sendmail!! Честито - person w3spi; 09.03.2018

към Windows8

след смяна

1-php.ini

2-sendmail.ini

отидете на C:\xampp\sendmail

  • 1) Щракнете с десния бутон върху sendmail.exe и отидете на свойства.
  • 2) щракнете върху раздела за съвместимост, след което щракнете върху промяна на настройките за всички потребители.
  • 3) задайте режим на съвместимост на Windows XP (Service Pack 3)
  • 4) щракнете върху квадратчето за стартиране на тази програма като администратор

Надявам се това да помогне на някой друг.

работи за мен

person user2698670    schedule 05.10.2015