- Published by
- Posted on
- 26 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 = "firstname.lastname@example.org"
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.