How to send emails using your localhost wamp, mamp, or xampp
- Published by
- Posted on
- 27 Comments
As a web developer many of us love to develop websites using a local server like wamp(Windows, Apache, Mysql, PHP), mamp(Mac, Apache, Mysql, PHP), or xampp(X (any of the four different operating systems), Apache, MySQL, PHP and Perl). Developing on a local server is very beneficial because you can change code without using the file manager or ftp and it is great for testing and debugging. Well if you’re like me I know you have ran into the sending a email using a localhost problem. In today’s post I will tell you guys how you can properly send an email using your localhost and hopefully saves you the headache.
Change your PHP.INI file
Open up your php.ini file and search for these lines of code. They should all be around each other.
[mail function] ; For Win32 only. ; http://php.net/smtp SMTP = "" ; http://php.net/smtp-port smtp_port = "25" ; For Win32 only. ; http://php.net/sendmail-from sendmail_from = ""
Change the follow code to match your current settings. I have tried this method using google smtp and windows live and did not have any luck but it could be different for you. If you have your own website and hosting go to your cpanel>>Email Accounts>>More>>Config Email Client and copy your mail settings. The settings you want to copy are incoming mail server and port number for that mail server.
[mail function] ; For Win32 only. ; http://php.net/smtp SMTP = "mail.yourdomain.com" ; http://php.net/smtp-port smtp_port = "port number" ; For Win32 only. ; http://php.net/sendmail-from sendmail_from = "name@yourdomain.com"
After you have successfully changed those line s of code in your php.ini file you must restart your local server to see the changes. I hope this had helped you solve your localhost mail issues and if you have any questions feel free to leave it below and I will be sure to answer you.
Great tip sir! Hopefully this fixes the issue I’ve had forever with WAMP… it’ll be nice to test all the mail functions in my Drupal and WordPress installs without a development server elsewhere!
Thanks! Yes it it very nice to send emails from a localhost
Have been looking for a long time, Ill try this in the morning. If it works, OhMyGod thanks.
ok and it should. Let me know if it works for you.
wow, your idea litmusonline@gmail.com
works, thanks for sharing.
wow, your idea works, thanks for sharing.
Hey Marcell, I can’t get it to work. I did exactly what you said but it’s not working for me…
Is your port number right? Also did you use your own email or email from google, bing?
Hi Marcel, this doesn’t work for me, but looking at the settings on my host, incoming mail is POP3 etc. No mention of SMTP is here except for outgoing email. Just for information in case any of your readers come across the same problem. Unless you know of any way around it?
Great post though, thanks for that, I can maybe pass it onto others.
Malky
you can use pop3 also. If you have your own host this should work. I had no luck with google, live, yahoo etc only with my personal domain
I am using Xampp, hope this work….
i dont have domain id, but i want to use from localhost server to send email in yahoo or gmail id, please tel me
Im not sure if yahoo or gmail works. I have tried gmail and live and were not able to connect but when I used my server it worked like a charm.
Marcell Sir,
please help me with this email service!
i too wish to send an email through a localhost to some non-local such as gmail or yahoo!
here i did not understand the concept of domain!
what domain sir???
how can i have a domain for myself! i work on a LAN! here domain means my IPaddress or what?
what do i have to specify there?
kindly give an example
please.! i desperately want to work this for me.
Thank You.!
By domain I mean your personal domain to your website. For example my domain name would be webdevtuts.net. You have to create an email using your domain account and of course you will need hosting in order for it to work.
got it sir!
means i have to buy a domain for myself!
and that domain will act as a smtp server..
please correct me! if am wrong!!
and aren’t there any free web sites
i googled few but dint succeed.!
thank you sir.
I’ve configured the above code for my local host “PHP.in” file. But, still I’m not able to send the mail’s. The error message it reflected when failed to send mail is :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 C:\wamp\www\mail\contact.php on line 1,
Please help me in this scenario
Which smtp server are using? Your own email server?
hi, i using wamp server. I want to send mail from localhost to web mail server like gmail, hotmail etc…how to do that? Is it i need to install mail server into my pc? how to configure it?
I am not sure if gmail or hotmail works with localhost. I have tried both and had no luck but using my own web server I was able to get it to send emails.
http://youhack.me/2010/04/01/building-a-registration-system-with-email-verification-in-php/
this is the module i want to apply into my web. But i fail the configure the email part and oways get tis error “Warning: mail() [function.mail]: Failed to connect to mailserver at “hotmail.com” port 25, verify your “SMTP” and “smtp_port” setting in php.ini or use ini_set() in C:\wamp\www\Registration_system_with_Email_Activation\index.php on line 69″…
can teach me how to solve this?
Hi Marcel. Thanks for the helpful post. I am trying to send mail from an apache2 localhost on Ubuntu. The mail function returns true but I don’t actually receive the email when I check my Gmail. I installed postfix and php5 could you point out what changes I should make to the configuration you originally posted?
I dont think it works with mail serves such as gmail, live etc only your own web server.
I have to send mail to gmail from local site.But it will be send by admin mail id which will be some company employee email id.
What should i have to do???
Ive tried google and had no luck. Do you have a cheap hosting account? You can get it then use the email feature and have gmail forward your email from your web server to gmail. I hope that makes sense.
Thanks for reply…
Actually I have intranet site…in that one survey module..after completing survey i have to send notification to admin…
Can you help me for it??
Iam using EasyPHP-12.1 as development tool.how do I use phpmailer to send email
a) from localhost to any other persons on hotmail,gmail,yahooetc
p’se help