Tuesday, January 11, 2011

Sending e-mail from localhost in PHP in Wamp Server

sendmail.exe is a simple windows console application that emulates sendmail's "-t" option to deliver emails piped via stdin.
  • download sendmail.zip 
  • eg. if your application is installed in C:\wamp, sendmail.exe and sendmail.ini need to be copied to C:\wamp\sendmail.exe and C:\wamp\sendmail.ini.
  • configure smtp server and default domain in sendmail.ini
 Modify in Senmail.ini


; smtp port (normally 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


; 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


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


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


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


Modify inside php.ini

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

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

save the file and restart wamp server 

1 comment:

  1. Getting this error
    Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\email\mail.php on line 4

    Please help ASAP