How to send email from localhost(XAMPP or WAMP) in PHP in Windows

Whenever you works in local server (XAMPP or WAMP) for developing any email functionality in website, than you might be wonder that why email is not going from localhost(XAMPP or WAMP) in windows environment. Well, i faced the same situation and in this case i can help you. Below is the error you might get when working with email.

“Warning: mail() [function.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”

Here i am showing you the way,how to send email from XAMPP or WAMP (localhost) in PHP in Windows.

1) Open the “php.ini”. For XAMPP,it is located in C:XAMPP/php/php.ini. Find out if you are using WAMPP server.

2) Search [mail function] in the php.ini file.

You can find like below.
[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25
; For Win32 only.
sendmail_from = me@localhost.com

Change the localhost to the smtp server name of your ISP. No need to change the smtp_port. Leave it as 25.
Change sendmail_from from me@localhost.com to your domain email address which will be used as from address..

So for me, it will become like this.
[mail function]
; For Win32 only.
SMTP = smtp.webddr.net
smtp_port = 25
; For Win32 only.
sendmail_from = info@webddr.net

3) Restart the XAMPP or WAMP(apache server) so that changes will start working.

4) Now try to send the mail using the mail() function ,

mail(“friend@gmail.com”,”Success”,”Thanks, that works”);

Well that’s all, now mail is sent to “friend@gmail.com” from the localhost.

Category: Tips and Tricks
Tags: | |

Newer post:
Older post:

2 Responses to “How to send email from localhost(XAMPP or WAMP) in PHP in Windows”

  1. Kerrie Eric says:

    As a teacher I grade a lot of writing assignments Thats a hard habit to break so I give you a strong A+ for this article Its interesting and well-written

  2. winnie says:

    That way cannot working port 25 are block by ISP. I have install main server it was working..but then cannot working..