Setting up email on localhost with PHP + PostCast Server
I recently had a great ballache with trying to test emails from my local machine. Testing emails is painful enough when it fucking works, nevermind when it doesn’t! I’d been putting off setting my system up for weeks but tonight i finally decided to give it a proper bash… And it worked!
This is how i did it… In 3 easy steps!
Step 1 – Configure your PHP to allow for SMTP connections
Firstly, you need to edit your php.ini file found in the php folder of your local server. I personally use XAMPP because it’s everything i need in a web server. XAMPP now has versions for Windows, Mac and Linux, so nobody has an excuse not to use it now.
In your PHP config file (php.ini), if you do a search for SMTP, you will find the following code:
; For Win32 only.
;SMTP = localhost
;smtp_port = 25
All you need to do is uncomment the last two lines (take out the semi-colons).
Step 2 – Download, install and configure PostCast Mail Server
PostCast Mail Server is a great, simple to use application that will allow you to send email from your local machine. Download and install the application. Once installed, go to Tools->Settings, and set your host name to localhost with a server port of 25. Once you’ve done that, you’re almost ready to go!
Step 3 – Send a mail
Create a file on your server called testmail.php and use the following code:
$headers = “From:email@example.com\r\n”.
“MIME-Version: 1.0\r\n” .
mail(“me@myaddress”,”PHP mail test”,”www.ria-coder.com/blog”, $headers);
And you’re done!
|Print article||This entry was posted by Danny Kopping on December 12, 2008 at 8:33 pm, and is filed under Lessons, PHP. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site.|
No trackbacks yet.
about 1 year ago - No comments
We’re looking for some skilled PHP developers to help us innovate with and improve on AMFPHP. If you think you’ve got the goods to help us get this project insanely powerful (but still simple and easy to use), drop us a line!
about 2 years ago - 2 comments
Here’s a very simple PHP class that i wrote to make thumbnail generation on JPG, PNG & GIF documents really simple and painless.
NOTE: You will need to have GD installed on your server for this class to work!
about 2 years ago - 2 comments
While working on a project lately, i needed a script that would allow me to find certain processes with PHP and inspect their running times, etc.
about 2 years ago - 4 comments
While working on a recent project, i needed to set up a cron job that would run every X amount of hours and backup a database Here’s a class i made to do just that!
about 3 years ago - No comments
The constructor function in Object-Oriented languages is an incredibly useful mechanism to use, and we’ve all used them for a wide variety of solutions.
about 3 years ago - 3 comments
Following from my previous post, i decided to try and mimick my development environment at work on my laptop. The quickest and easiest way to do this is to install XAMPP for Linux. The folks over at apachefriends have given us one of the greatest gifts a web-developer geek could want… A pre-configured, fully open
about 3 years ago - 23 comments
Yesterday i recorded a video tutorial on integrating Flex, AMFPHP and CodeIgniter. This tutorial will walk you through each step of the process. If you have any questions, please post them as comments and i’ll answer them as best i can.
about 3 years ago - 10 comments
While working on a project today, i encountered a serious ballache in the form of this: mx.rpc.Fault (@14f27331) [inherited] faultCode “Server.Acknowledge.Failed” faultDetail “Was expecting message ’93EDDF20-516F-2C3F-AA63-619BAB9DA793′ but received ”.” faultString “Didn’t receive an acknowledgement of message” rootCause null AMFPHP, for all it’s wonder and usefulness, doesn’t document its errors very well. Very irritating. After much
about 3 years ago - 20 comments
A while back i spent an evening hacking away at the CodeIgniter source code. I was desperate to use it as a library, as opposed to a framework. I don’t use PHP with HTML. I did for a little bit, but personally i found that HTML and CSS were the biggest load of shit languages