2011-02-09 93 views
18

Estoy intentando configurar Sendmail a través de XAMPP para enviar correos electrónicos. En mi sendmail.ini tengo estos ajustes:XAMPP Sendmail usando la cuenta de Gmail

# Set default values for all following accounts. 

logfile "C:\xampp\sendmail\sendmail.log 
account Gmail 
tls on 
port 587 
tls_certcheck off 
host smtp.gmail.com 
from [email protected] 
auth on 
user [email protected] 
password mypassword 

account default : Gmail 

que he creado un script de prueba como esta:

$to = "[email protected]"; 
$subject = "Hi!"; 
$body = "Hi,\n\nHow are you?"; 
$headers = "From: [email protected]" . "\r\n"; 
if (mail($to, $subject, $body, $headers)) { 
    echo ("Message successfully sent!"); 
} else { 
    echo ("Message delivery failed..."); 
} 

me sale un mensaje diciendo que el correo electrónico fue enviado pero nunca llega y en los registros de recibo:

sendmail: Error durante el parto: Se debe emitir un comando STARTTLS primero.

¿Alguien sabe cuál es el problema podría estar aquí?

¡Gracias de antemano!

Gaz

+0

¿Soy el único en notar que OP está preguntando por ** original 'sendmail' ** - el agente de transferencia de correo más famoso del mundo ([información en Wiki] (http://en.wikipedia.org/wiki)/Sendmail)), comenzó en 1979, mientras que la mayoría de las respuestas son acerca de ** fake 'sendmail' ** ([homepage] (http://glob.com.au/sendmail/)) - un programa falso utilizado en los paquetes de servidores de desarrollo, como XAMPP, comenzaron en 2004. ¿No pueden ver las personas que el ejemplo del archivo de configuración proporcionado por OP es tan diferente de los ejemplos de configuración que usted brinda en sus respuestas? Extraño. – trejder

Respuesta

35

Esto es lo que funcionó para mí Esperemos que nadie más va a quemar el aceite de resolver esto como yo lo hice.

Aquí es mi sendmail.ini

[sendmail] 

smtp_server=smtp.gmail.com 
smtp_port=25 
error_logfile=error.log 
debug_logfile=debug.log 
[email protected] 
auth_password=yourgmailpassword 
[email protected] 

php/php.ini ---- básicamente comenta todo sale sino sendmail_path & mail.add_x_header

[mail function] 
; For Win32 only. 
; http://php.net/smtp 
;SMTP = localhost 
; http://php.net/smtp-port 
;smtp_port = 25 

; For Win32 only. 
; http://php.net/sendmail-from 
;sendmail_from = [email protected] 

; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). 
; http://php.net/sendmail-path 
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t" 

; 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 = Off 

; Log all mail() calls including the full path of the script, line #, to address and headers 
;mail.log = "C:\xampp\apache\logs\php_mail.log" 

Esto funcionó para mí después de ser informado los archivos sendmail (los anteriores no admiten smtp)

  • vaya a http://glob.com.au/sendmail/ an d agarrar el último Sendmail archivo zip
  • descomprimir al escritorio y copiar los archivos en el \ xampp \ carpeta de Sendmail reemplazar todo lo que estaba there.EVERYTHING!
  • Ahora abra sendmail.ini y copie y pegue lo que mostré anteriormente. (Elimine todo en ese archivo primero o simplemente coméntelo todo)
  • NOTA: no necesita servidores de Mercury iniciados para esto.

Estaba haciendo una recuperación de contraseña php en localhost cuando encontré este problema. Necesitaba enviarles a los usuarios su contraseña. - PHP busca su okey

+1

Esto funcionó de manera brillante para mí. Solo para agregar una nota de ahorro de tiempo: Recuerde reiniciar Apache después de alterar los archivos de configuración. – KalenGi

+0

Dijiste "los viejos no son compatibles con smtp", pero creo que querías decir "los viejos no admiten TLS". – D0SBoots

+1

Tengo 2 notas más: 1) Tuve que habilitar aplicaciones menos seguras para acceder a mi cuenta de Gmail (vaya a Gmail> Cuenta> Seguridad); 2) Tuve que usar el puerto 587 en lugar de 25. – FlavioEscobar

0

a) Cambio php.ini Localizar php.ini en la ruta del archivo “[letra de unidad]: [XAMPP directorio] \ php”. p.ej. C: \ xampp \ php \ php.ini

Busque sendmail_path en su archivo php.ini y elimine el punto y coma ";" antes que [el mío no tenía la ruta].

[mail function] 
; For Win32 only. 

SMTP = smtp.gmail.com 

smtp_port = 25 

; For Win32 only. 
; http://php.net/sendmail-from 
sendmail_from = [your_gmail_username]@gmail.com 
sendmail_path = "\"C:\xampplite\sendmail\sendmail.exe\" -t" 

b) Cambio sendmail.ini Localizar sendmail.ini en la ruta del archivo es “[letra de unidad]: [directorio XAMPP] \ sendmail”, por ejemplo, C: \ xampp \ Sendmail \ sendmail.ini

comentario a los y “Un ejemplo servicio de correo gratuito” contenido “Mercury”, como se muestran a continuación:

# Mercury <br/> 
#account Mercury <br/> 
#host localhost <br/> 
#from [email protected] <br/> 
#auth off <br/> 
# A freemail service example <br/> 
#account Hotmail <br/> 
#tls on <br/> 
#tls_certcheck off <br/> 
#host smtp.live .com <br/> 
#from [exampleuser]@hotmail.com <br/> 
#auth on <br/> 
#user [exampleuser]@hotmail .com <br/> 
#password [examplepassword] <br/> 

c. Agrega la cuenta de gmail.

Ejemplo:

account Gmail 
tls on 
tls_certcheck off 
host smtp.gmail.com 
from [your_gmail_username]@gmail.com 
auth on 
    account default : Gmail 

d. Reinicie Apache Server


No utilicé gmail. Usé mi cuenta de hosting. Si lo hace, asegúrese de que la configuración de SMTP sea correcta. El mío fue mail.abc.com, no smtp.gmail.com. Este código es de 2 sitios web. Necesita cambiar ambos archivos. Lo tengo trabajando en Xampp 1.73 ejecutándose en una caja win200sp4. Toda la configuración predeterminada excepto estos dos archivos. php.ini y sendmail.ini

13

Bien, hoy, la mejor respuesta no funcionó para mí. Sin embargo, esto no hizo:

en sendmail.ini:

[sendmail] 
smtp_server=smtp.gmail.com 
smtp_port=587 
error_logfile=error.log 
debug_logfile=debug.log 
auth_username=****@gmail.com 
auth_password=******* 
force_sender=****@gmail.com 

en php.ini:

[mail function] 
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t" 

Con base en el puerto @: http://support.google.com/mail/bin/answer.py?hl=en&answer=13287

0

No es otra problema al usar Gmail. Gmail ahora tiene seguridad, por lo que debe generar una contraseña específica de la aplicación; no puede usar la contraseña que tiene para su acceso normal a Gmail. Descubrí esto probando los ejemplos anteriores y luego notando que en la carpeta sendmail se había generado un registro de errores. En el registro de errores me encontré con un mensaje que indica esto.

+0

Lo intenté con mi cuenta y funcionó, pero solo con el puerto 465 – webeno

0

Sé que esta es una publicación antigua, pero pensé que compartiría el hecho de que lo siguiente funcionó para mí.

Actualmente estoy usando un servidor WAMP en Windows 7 ENT con Apache/2.4.9 (Win64) PHP/5.5.12 y MySQL 5.6.17.

he seguido este tutorial: http://blog.techwheels.net/send-email-from-localhost-wamp-server-using-sendmail/

+0

Aunque este enlace puede responder la pregunta, es mejor incluir las partes esenciales de la respuesta aquí y proporcione el enlace de referencia. Las respuestas solo de enlace pueden dejar de ser válidas si la página vinculada cambia – Marusyk

0
THIS IS WHAT YOU SENDMAIL SHOULD LOOK LIKE 


[sendmail] 

; you must change mail.mydomain.com to your smtp server, 
; or to IIS's "pickup" directory. (generally C:\Inetpub\mailroot\Pickup) 
; emails delivered via IIS's pickup directory cause sendmail to 
; run quicker, but you won't get error messages back to the calling 
; application. 

smtp_server=smtp.gmail.com 

; smtp port (normally 25) 

smtp_port=465 

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

smtp_ssl=auto 

; the default domain for this server will be read from the registry 
; this will be appended to email addresses when one isn't provided 
; if you want to override the value in the registry, uncomment and modify 

;default_domain=mydomain.com 

; log smtp errors to error.log (defaults to same directory as sendmail.exe) 
; uncomment to enable logging 

error_logfile=error.log 

; create debug log as debug.log (defaults to same directory as sendmail.exe) 
; uncomment to enable debugging 

debug_logfile=debug.log 

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

auth_username=Your Email Here 
auth_password=Your Password Here 

; if your smtp server uses pop3 before smtp authentication, modify the 
; following three lines. do not enable unless it is required. 

pop3_server= 
pop3_username= 
pop3_password= 

; force the sender to always be the following email address 
; this will only affect the "MAIL FROM" command, it won't modify 
; the "From: " header of the message content 

force_sender=Your Email Here 

; force the sender to always be the following email address 
; this will only affect the "RCTP TO" command, it won't modify 
; the "To: " header of the message content 

force_recipient= 

; sendmail will use your hostname and your default_domain in the ehlo/helo 
; smtp greeting. you can manually set the ehlo/helo name if required 

hostname=smtp.gmail.com 

THIS IS WHAT YOU PHP.INI FILE SHOULD LOOK LIKE 

[mail function] 
; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury 
smtp_server=smtp.gmail.com 
smtp_port = 465 

; For Win32 only. 
; http://php.net/sendmail-from 
;sendmail_from = [email protected] 

; 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=Off 
1

Estos son los más recientes requisitos del servidor SMTP: Google

  1. dirección del servidor SMTP de Gmail: smtp.gmail.com
  2. Gmail SMTP contraseña: (Tu contraseña de Gmail)
  3. puerto SMTP de Gmail (TLS):
  4. puerto SMTP de Gmail (SSL):
  5. Gmail SMTP TLS/SSL requerido: Sí

Google SMTP Requirements

Si solo usa SSL, se complica con la prueba de verificación de Captcha requerida, así que configuro mi SSL en automático, que probará TLS cuando SSL falle.
enter image description here

1

Solo para agregar a las ya grandes respuestas. Asegúrese de ejecutar XAMPP como administrador. Eso fue lo que me solucionó.

Cuestiones relacionadas