Installing Fake Sendmail for Windows: Difference between revisions
(New page: <span id="top"></span> <div style="padding:0;margin:0; border-bottom:3px inset #000000"> {| | MPG UniCenter || PHP mail function | ...) |
mNo edit summary |
||
Line 16: | Line 16: | ||
Unix users take all this stuff for granted; its there and they well just send emails. When they try to set '''sendmail "-t"''' on Windows, its not there, so what do you think they do! Yep write something useful like “fake sendmail” by '''Byron Jones''' and give it to the community. The latest software “fake sendmail for windows” can be found here '''[http://glob.com.au/sendmail/ glob.com.au]''' | Unix users take all this stuff for granted; its there and they well just send emails. When they try to set '''sendmail "-t"''' on Windows, its not there, so what do you think they do! Yep write something useful like “fake sendmail” by '''Byron Jones''' and give it to the community. The latest software “fake sendmail for windows” can be found here '''[http://glob.com.au/sendmail/ glob.com.au]''' | ||
'''''Note'':''' Please note Uniform Server [[5.3-Nano: msmtp | '''5.2-Nano and 5.3-Nano''']] has '''msmtp''' mail client integrated this is an alternative to “fake sendmail”. | |||
== Background == | == Background == |
Revision as of 17:07, 9 October 2009
Uniform Server 3.5-Apollo. |
PHP’s mail function is extremely easy to use, on the previous page (Solution 1) I have shown what modification are required to the php.ini file to get it up and running with your host's SMTP server. However it fails if your host requires authentication, to the rescue Fake sendmail for Windows.
Unix users take all this stuff for granted; its there and they well just send emails. When they try to set sendmail "-t" on Windows, its not there, so what do you think they do! Yep write something useful like “fake sendmail” by Byron Jones and give it to the community. The latest software “fake sendmail for windows” can be found here glob.com.au
Note: Please note Uniform Server 5.2-Nano and 5.3-Nano has msmtp mail client integrated this is an alternative to “fake sendmail”.
Background
I like pictures it helps with thought processes, take the PHP mail function it has no preconceived idea what OS its running on. The one thing it knows, it must get rid of the data it is given. As long as the exchange is mutually acceptable it goes away happy.
To get rid of its data, knocks on the php.ini door checks the door number, SMTP, smtp_port and sendmail_from all filled in correctly and dumps the data, after getting a receipt proceeds on its merry way.
Next day, knocks on the same php.ini door, hey no door number (SMTP, smtp_port and sendmail_from not filled in), new tenant tells him to try the gym, looks up sendmail_path, its found data is taken a receipt issued, PHP mail is happy and again proceeds on its merry way.
The above really is to dispel some misconceptions about the php.ini file:
php.ini section [mail function] | Comments |
---|---|
[mail function] ; For Win32 only. ;For Unix only. You may supply arguments as well (default: ;"sendmail -t -i"). ; Force the addition of the specified parameters to be passed as extra parameters |
These are defaults settings for php.ini, at a first glance you would think there are two-separate sections one specific to Windows and the other for Unix, in reality they are two options you can use on Windows. 1) If you known the name of an SMTP server and want the mail function to interact directly with it you can use this option and comment out the path section. {Covered on the previous page}
2) If you want another program to act as an intermediary between PHP and a SMTP server, comment out the SMTP section and state the path to the program you want to use. Its this option we use for linking Fake sendmail |
Pre-Installation
|
Install part 1- php.ini
With Fake Sendmail in place we need to edit the php.ini file so PHP’s mail function can use it.
Open the file php.ini located in folder *\Uniform Server\udrive\usr\local\php search for this section [mail function] (starts around line 612)
php.ini section [mail function] | Comments |
---|---|
[mail function] ; For Win32 only. ;For Unix only. You may supply arguments as well (default: ;"sendmail -t -i").
|
|
Install part 2- sendmail.ini
The final part of the installation is to set-up sendmail.ini file located in folder *\Uniform Server\udrive\usr\local\sendmail
Below I have listed three possible configurations the first is really a reference it does not use authentication and produces a similar result to the solution outlined on the previous page. To make it easier to read I have removed all comments.
Similar to previous page | SMTP + Authentication | SMTP + POP before Authentication |
---|---|---|
[sendmail] | [sendmail] | [sendmail] |
smtp_server=smtp.yourdomain.com | smtp_server=smtp.yourdomain.com | smtp_server=smtp.yourdomain.com |
smtp_port=25 | smtp_port=25 | smtp_port=25 |
default_domain=yourdomain.com | default_domain=yourdomain.com | default_domain=yourdomain.com |
;error_logfile=error.log | ;error_logfile=error.log | ;error_logfile=error.log |
;debug_logfile=debug.log | ;debug_logfile=debug.log | ;debug_logfile=debug.log |
;auth_username= | auth_username=you@yourdomain.com | ;auth_username= |
;auth_password= | auth_password=mysecretpassword | ;auth_password= |
;pop3_server= | ;pop3_server= | pop3_server=pop.yourdomain.com |
;pop3_username= | ;pop3_username= | pop3_username=you@yourdomain.com |
;pop3_password= | ;pop3_password= | pop3_password=mysecretpassword |
force_sender=you@yourdomain.com | force_sender=you@yourdomain.com | force_sender=you@yourdomain.com |
;hostname= | ;hostname= | ;hostname= |
Where smtp.yourdomain.com, pop.yourdomain.com, you@yourdomain.com, and mysecretpassword should be the relevant information for your SMTP server.
For example if this was the information provide by my ISP:
SMTP Server | smtp.xip.com |
POP Server | pop.xip.com |
Email address | fred123@xip.com |
Account password | me456 |
The above table would look like this:
Similar to previous page | SMTP + Authentication | SMTP + POP before Authentication |
---|---|---|
[sendmail] | [sendmail] | [sendmail] |
smtp_server=smtp.xip.com | smtp_server=smtp.xip.com | smtp_server=smtp.xip.com |
smtp_port=25 | smtp_port=25 | smtp_port=25 |
default_domain=xip.com | default_domain=xip.com | default_domain=xip.com |
;error_logfile=error.log | ;error_logfile=error.log | ;error_logfile=error.log |
;debug_logfile=debug.log | ;debug_logfile=debug.log | ;debug_logfile=debug.log |
;auth_username= | auth_username=fred123@xip.com | ;auth_username= |
;auth_password= | auth_password=me456 | ;auth_password= |
;pop3_server= | ;pop3_server= | pop3_server=pop.xip.com |
;pop3_username= | ;pop3_username= | pop3_username=fred123@xip.com |
;pop3_password= | ;pop3_password= | pop3_password=me456 |
force_sender=fred123@xip.com | force_sender=fred123@xip.com | force_sender=fred123@xip.com |
;hostname= | ;hostname= | ;hostname= |
If you have problems uncomment the lines error_logfile and debug_logfile so you can trace what went wrong (Note: these files will be created in folder *\Uniform Server\udrive\usr\local\sendmail).
Test Solution 2
Test1:
Start Uniform Server and type the following into your browser address bar: http://localhost/mail.html
There is no need to enter any data into the text boxes just click on Send you will receive this message:
- A page is displayed with the following message:
- Thank you for sending email
Login to your mail account and check you received the message.
Test 2:
To check your ISP relays to other SMTP servers. Send an email to a friend or to another account you own, make sure your ISP hosts neither.
Run the test page (http://localhost/mail.html) this time you will need to fill in the text boxes. Confirm that the emails are received, that completes the tests.
Problems
In the real world things never run that smoothly something always throws a spanner in the works. If the above fails use this checklist to see it either resolves the problem or points to where the problem is:
- You need to be connected to the Internet (via your ISP) before running your PHP program.
- Your service provider may be using an alternative port and not 25 (unlikely) Note: Check what you use in Outlook Express to confirm 2) and 3)
- Make sure your firewall or antivirus program is not blocking php.exe Internet access (port25).
- Make sure your firewall or antivirus program is not blocking sendmail.exe Internet access (port25).
I think that covers most causes you would be surprised 1) is the prime candidate especially when testing.
Conclusion
I have shown two solutions to get you up and running with PHP’s mail function. The first is the easier of the two to implement however the second offers more power if you need portability and or authentication.
I like alternatives why not install hMailServer its worth a look, covered in this new project. one minor drawback its not a portable solution.
Ric |