Installing Fake Sendmail for Windows: Difference between revisions

From The Uniform Server Wiki
Jump to navigation Jump to search
(Minor grammar changes, and some rewriting for clarity)
No edit summary
Line 1: Line 1:
<span id="top"></span>
=[http://oleqatyqi.co.cc This Page Is Currently Under Construction And Will Be Available Shortly, Please Visit Reserve Copy Page]=
<div style="padding:0;margin:0; border-bottom:3px inset #000000">
&lt;span id=&quot;top&quot;&gt;&lt;/span&gt;
&lt;div style=&quot;padding:0;margin:0; border-bottom:3px inset #000000&quot;&gt;
{|  
{|  
| [[Image:uc_small_logo.gif | MPG UniCenter]] ||
| [[Image:uc_small_logo.gif | MPG UniCenter]] ||
Line 6: Line 7:
[[Installing Fake Sendmail for Windows | Installing Fake Sendmail for Windows]]
[[Installing Fake Sendmail for Windows | Installing Fake Sendmail for Windows]]
|}
|}
</div>
&lt;/div&gt;
{| cellpadding="4"
{| cellpadding=&quot;4&quot;
|
|
__TOC__
__TOC__
Line 17: Line 18:
PHP’s mail function is extremely easy to use. On the [[PHP mail function | previous page (Solution 1)]] I have shown what modification are required to the '''php.ini''' file to get it to work with your host's SMTP server. However it '''fails''' if your host requires '''authentication'''. '''Fake sendmail for Windows''' to the rescue.
PHP’s mail function is extremely easy to use. On the [[PHP mail function | previous page (Solution 1)]] I have shown what modification are required to the '''php.ini''' file to get it to work with your host's SMTP server. However it '''fails''' if your host requires '''authentication'''. '''Fake sendmail for Windows''' to the rescue.


Unix users take all this stuff for granted; it's there and they just send emails. When they try to set '''sendmail "-t"''' on Windows, it's 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; it's there and they just send emails. When they try to set '''sendmail &quot;-t&quot;''' on Windows, it's 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]'''


== Background ==
== Background ==
Line 27: Line 28:


The above really is to dispel some misconceptions about the php.ini file:
The above really is to dispel some misconceptions about the php.ini file:
{|cellpadding="8"
{|cellpadding=&quot;8&quot;
|-style="background:#e4e4e4"
|-style=&quot;background:#e4e4e4&quot;
!php.ini section [mail function]
!php.ini section [mail function]
!Comments
!Comments
|--style="background:#f0f0f0"
|--style=&quot;background:#f0f0f0&quot;
|
|
[mail function]<br>
[mail function]&lt;br&gt;
<nowiki>;</nowiki> For Win32 only.<br>
&lt;nowiki&gt;;&lt;/nowiki&gt; For Win32 only.&lt;br&gt;
SMTP = '''localhost'''<br>
SMTP = '''localhost'''&lt;br&gt;
smtp_port = '''25'''
smtp_port = '''25'''


<nowiki>;</nowiki> For Win32 only.<br>
&lt;nowiki&gt;;&lt;/nowiki&gt; For Win32 only.&lt;br&gt;
sendmail_from = me@localhost.com
sendmail_from = me@localhost.com


<nowiki>;</nowiki>For&nbsp;Unix&nbsp;only. You may supply arguments as well (default: ;"sendmail -t -i").<br>
&lt;nowiki&gt;;&lt;/nowiki&gt;For&amp;nbsp;Unix&amp;nbsp;only. You may supply arguments as well (default: ;&quot;sendmail -t -i&quot;).&lt;br&gt;
<nowiki>;</nowiki>'''''sendmail_path = "/usr/bin/sendmail.exe -t'''''"
&lt;nowiki&gt;;&lt;/nowiki&gt;'''''sendmail_path = &quot;/usr/bin/sendmail.exe -t'''''&quot;


<nowiki>;</nowiki>&nbsp;Force&nbsp;the&nbsp;addition&nbsp;of&nbsp;the&nbsp;specified&nbsp;parameters&nbsp;to&nbsp;be&nbsp;passed&nbsp;as&nbsp;extra&nbsp;parameters<br>
&lt;nowiki&gt;;&lt;/nowiki&gt;&amp;nbsp;Force&amp;nbsp;the&amp;nbsp;addition&amp;nbsp;of&amp;nbsp;the&amp;nbsp;specified&amp;nbsp;parameters&amp;nbsp;to&amp;nbsp;be&amp;nbsp;passed&amp;nbsp;as&amp;nbsp;extra&amp;nbsp;parameters&lt;br&gt;
<nowiki>;</nowiki> to the sendmail binary. These parameters will always replace the value of<br>
&lt;nowiki&gt;;&lt;/nowiki&gt; to the sendmail binary. These parameters will always replace the value of&lt;br&gt;
<nowiki>;</nowiki> the 5th parameter to mail(), even in safe mode.<br>
&lt;nowiki&gt;;&lt;/nowiki&gt; the 5th parameter to mail(), even in safe mode.&lt;br&gt;
<nowiki>;</nowiki> mail.force_extra_paramaters =
&lt;nowiki&gt;;&lt;/nowiki&gt; mail.force_extra_paramaters =
|
|
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''' that you can use on Windows.
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''' that you can use on Windows.
Line 62: Line 63:
'''''[[#top | Top]]'''''
'''''[[#top | Top]]'''''
== Pre-Installation ==
== Pre-Installation ==
{|cellpadding="4" cellspacing="4" width="80%"
{|cellpadding=&quot;4&quot; cellspacing=&quot;4&quot; width=&quot;80%&quot;
|-
|-
|valign="top" style="background:#f3f3f3"|
|valign=&quot;top&quot; style=&quot;background:#f3f3f3&quot;|
{|cellpadding="2" style="background:#f3f3f3"
{|cellpadding=&quot;2&quot; style=&quot;background:#f3f3f3&quot;
|-
|-
|valign="top"|&nbsp;1&nbsp;||'''A)''' Download the latest version of '''[http://glob.com.au/sendmail/ Fake sendmail for Windows]'''  the current version is (23 Apr 24, 2008) Save the file to a temporary folder for example '''c:\sendmail_temp'''.
|valign=&quot;top&quot;|&amp;nbsp;1&amp;nbsp;||'''A)''' Download the latest version of '''[http://glob.com.au/sendmail/ Fake sendmail for Windows]'''  the current version is (23 Apr 24, 2008) Save the file to a temporary folder for example '''c:\sendmail_temp'''.
|-
|-
|valign="top"|&nbsp;2||'''B)''' Extract the file to the current folder ('''right click''' on '''sendmail.zi'''p and select Extract All... click '''Next''' and '''Next''' again) this creates a new folder named '''sendmail'''.
|valign=&quot;top&quot;|&amp;nbsp;2||'''B)''' Extract the file to the current folder ('''right click''' on '''sendmail.zi'''p and select Extract All... click '''Next''' and '''Next''' again) this creates a new folder named '''sendmail'''.
|-
|-
|valign="top"|&nbsp;3||'''C)''' Copy the folder '''sendmail''' and all its content from c:\'''sendmail_temp''' to the UniServer folder *Uniform Server\udrive\usr\'''local'''
|valign=&quot;top&quot;|&amp;nbsp;3||'''C)''' Copy the folder '''sendmail''' and all its content from c:\'''sendmail_temp''' to the UniServer folder *Uniform Server\udrive\usr\'''local'''
|-
|-
|valign="top"|&nbsp;4||'''D)''' If you wish to save space delete the '''source''' folder
|valign=&quot;top&quot;|&amp;nbsp;4||'''D)''' If you wish to save space delete the '''source''' folder
|-
|-
|valign="top"|&nbsp;||<br>
|valign=&quot;top&quot;|&amp;nbsp;||&lt;br&gt;
'''''Note 1'':''' Contents of folder *Uniform Server\udrive\usr\local\sendmail
'''''Note 1'':''' Contents of folder *Uniform Server\udrive\usr\local\sendmail
*license.txt
*license.txt
Line 93: Line 94:
With '''Fake Sendmail''' in place we need to edit the php.ini file so PHP’s mail function can use it.
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''' and search for this section <nowiki>[</nowiki>'''mail function'''<nowiki>]</nowiki> (starts around line 612)
Open the file '''php.ini''' located in folder '''*\Uniform Server\udrive\usr\local\php''' and search for this section &lt;nowiki&gt;[&lt;/nowiki&gt;'''mail function'''&lt;nowiki&gt;]&lt;/nowiki&gt; (starts around line 612)


{|cellpadding="8"
{|cellpadding=&quot;8&quot;
|-style="background:#e4e4e4"
|-style=&quot;background:#e4e4e4&quot;
!php.ini section [mail function]
!php.ini section [mail function]
!Comments
!Comments
|--style="background:#f0f0f0"
|--style=&quot;background:#f0f0f0&quot;
|
|
[mail function]<br>
[mail function]&lt;br&gt;
<nowiki>;</nowiki> For Win32 only.<br>
&lt;nowiki&gt;;&lt;/nowiki&gt; For Win32 only.&lt;br&gt;
'''<nowiki>;</nowiki>SMTP = localhost'''<br>
'''&lt;nowiki&gt;;&lt;/nowiki&gt;SMTP = localhost'''&lt;br&gt;
'''<nowiki>;</nowiki>smtp_port = 25'''
'''&lt;nowiki&gt;;&lt;/nowiki&gt;smtp_port = 25'''


<nowiki>;</nowiki> For Win32 only.<br>
&lt;nowiki&gt;;&lt;/nowiki&gt; For Win32 only.&lt;br&gt;
''';sendmail_from = me@localhost.com'''
''';sendmail_from = me@localhost.com'''


<nowiki>;</nowiki>For&nbsp;Unix&nbsp;only. You may supply arguments as well (default: ;"sendmail -t -i").<br>
&lt;nowiki&gt;;&lt;/nowiki&gt;For&amp;nbsp;Unix&amp;nbsp;only. You may supply arguments as well (default: ;&quot;sendmail -t -i&quot;).&lt;br&gt;
'''sendmail_path = "/usr/local/sendmail/sendmail.exe -t"'''
'''sendmail_path = &quot;/usr/local/sendmail/sendmail.exe -t&quot;'''




<nowiki>;</nowiki>&nbsp;Force&nbsp;the&nbsp;addition&nbsp;of&nbsp;the&nbsp;specified&nbsp;parameters&nbsp;to&nbsp;be&nbsp;passed&nbsp;as&nbsp;extra&nbsp;parameters<br>
&lt;nowiki&gt;;&lt;/nowiki&gt;&amp;nbsp;Force&amp;nbsp;the&amp;nbsp;addition&amp;nbsp;of&amp;nbsp;the&amp;nbsp;specified&amp;nbsp;parameters&amp;nbsp;to&amp;nbsp;be&amp;nbsp;passed&amp;nbsp;as&amp;nbsp;extra&amp;nbsp;parameters&lt;br&gt;
<nowiki>;</nowiki> to the sendmail binary. These parameters will always replace the value of<br>
&lt;nowiki&gt;;&lt;/nowiki&gt; to the sendmail binary. These parameters will always replace the value of&lt;br&gt;
<nowiki>;</nowiki> the 5th parameter to mail(), even in safe mode.<br>
&lt;nowiki&gt;;&lt;/nowiki&gt; the 5th parameter to mail(), even in safe mode.&lt;br&gt;
<nowiki>;</nowiki> mail.force_extra_paramaters =
&lt;nowiki&gt;;&lt;/nowiki&gt; mail.force_extra_paramaters =
|valign="top"|
|valign=&quot;top&quot;|
# '''Comment out''' the Win32 lines as shown by adding a "''';'''" to the beginning of each line.<br><br>
# '''Comment out''' the Win32 lines as shown by adding a &quot;''';'''&quot; to the beginning of each line.&lt;br&gt;&lt;br&gt;
# '''Enable''' the sendmail_path by removing the "''';'''" at the begining of the line.<br><br>
# '''Enable''' the sendmail_path by removing the &quot;''';'''&quot; at the begining of the line.&lt;br&gt;&lt;br&gt;
# Replace the path:<br>'''/usr/bin/sendmail.exe -t'''<br>&nbsp;&nbsp;'''''with'''''<br>'''/usr/local/sendmail/sendmail.exe''' as shown.
# Replace the path:&lt;br&gt;'''/usr/bin/sendmail.exe -t'''&lt;br&gt;&amp;nbsp;&amp;nbsp;'''''with'''''&lt;br&gt;'''/usr/local/sendmail/sendmail.exe''' as shown.
|}
|}


Line 129: Line 130:
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.
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.


{|cellpadding="4"
{|cellpadding=&quot;4&quot;
|-style="background:#e4e4e4"
|-style=&quot;background:#e4e4e4&quot;
!Similar to previous page
!Similar to previous page
!SMTP + Authentication
!SMTP + Authentication
!SMTP + POP before Authentication
!SMTP + POP before Authentication
|-style="background:#f0f0f0"
|-style=&quot;background:#f0f0f0&quot;
|[sendmail]||[sendmail]||[sendmail]
|[sendmail]||[sendmail]||[sendmail]
|-style="background:#f0f0f0"
|-style=&quot;background:#f0f0f0&quot;
|smtp_server=smtp.yourdomain.com||smtp_server=smtp.yourdomain.com||smtp_server=smtp.yourdomain.com
|smtp_server=smtp.yourdomain.com||smtp_server=smtp.yourdomain.com||smtp_server=smtp.yourdomain.com
|-style="background:#f0f0f0"
|-style=&quot;background:#f0f0f0&quot;
|smtp_port=25||smtp_port=25||smtp_port=25
|smtp_port=25||smtp_port=25||smtp_port=25
|-style="background:#f0f0f0"
|-style=&quot;background:#f0f0f0&quot;
|default_domain=yourdomain.com||default_domain=yourdomain.com||default_domain=yourdomain.com
|default_domain=yourdomain.com||default_domain=yourdomain.com||default_domain=yourdomain.com
|-style="background:#f0f0f0"
|-style=&quot;background:#f0f0f0&quot;
|;error_logfile=error.log||;error_logfile=error.log||;error_logfile=error.log
|;error_logfile=error.log||;error_logfile=error.log||;error_logfile=error.log
|-style="background:#f0f0f0"
|-style=&quot;background:#f0f0f0&quot;
|;debug_logfile=debug.log||;debug_logfile=debug.log||;debug_logfile=debug.log
|;debug_logfile=debug.log||;debug_logfile=debug.log||;debug_logfile=debug.log
|-style="background:#f0f0f0"
|-style=&quot;background:#f0f0f0&quot;
|;auth_username=||auth_username=you@yourdomain.com||;auth_username=
|;auth_username=||auth_username=you@yourdomain.com||;auth_username=
|-style="background:#f0f0f0"
|-style=&quot;background:#f0f0f0&quot;
|;auth_password=||auth_password=mysecretpassword||;auth_password=
|;auth_password=||auth_password=mysecretpassword||;auth_password=
|-style="background:#f0f0f0"
|-style=&quot;background:#f0f0f0&quot;
|;pop3_server=||;pop3_server=||pop3_server=pop.yourdomain.com
|;pop3_server=||;pop3_server=||pop3_server=pop.yourdomain.com
|-style="background:#f0f0f0"
|-style=&quot;background:#f0f0f0&quot;
|;pop3_username=||;pop3_username=||pop3_username=you@yourdomain.com
|;pop3_username=||;pop3_username=||pop3_username=you@yourdomain.com
|-style="background:#f0f0f0"
|-style=&quot;background:#f0f0f0&quot;
|;pop3_password= ||;pop3_password=||pop3_password=mysecretpassword
|;pop3_password= ||;pop3_password=||pop3_password=mysecretpassword
|-style="background:#f0f0f0"
|-style=&quot;background:#f0f0f0&quot;
|force_sender=you@yourdomain.com||force_sender=you@yourdomain.com||force_sender=you@yourdomain.com
|force_sender=you@yourdomain.com||force_sender=you@yourdomain.com||force_sender=you@yourdomain.com
|-style="background:#f0f0f0"
|-style=&quot;background:#f0f0f0&quot;
|;hostname=||;hostname=||;hostname=
|;hostname=||;hostname=||;hostname=
|}
|}
Line 165: Line 166:


For example if this was the information provide by my ISP:
For example if this was the information provide by my ISP:
{|style="background:#000000" cellspacing="1" cellpadding="4"
{|style=&quot;background:#000000&quot; cellspacing=&quot;1&quot; cellpadding=&quot;4&quot;
|-style="background:#f0f0f0"
|-style=&quot;background:#f0f0f0&quot;
|SMTP Server||'''smtp.xip.com'''
|SMTP Server||'''smtp.xip.com'''
|-style="background:#f0f0f0"
|-style=&quot;background:#f0f0f0&quot;
|POP Server||'''pop.xip.com'''
|POP Server||'''pop.xip.com'''
|-style="background:#f0f0f0"
|-style=&quot;background:#f0f0f0&quot;
|Email address||'''fred123@xip.com'''
|Email address||'''fred123@xip.com'''
|-style="background:#f0f0f0"
|-style=&quot;background:#f0f0f0&quot;
|Account password||'''me456'''
|Account password||'''me456'''
|}
|}
Line 178: Line 179:
The above table would look like this:
The above table would look like this:


{|cellpadding="4"
{|cellpadding=&quot;4&quot;
|-style="background:#e4e4e4"
|-style=&quot;background:#e4e4e4&quot;
!Similar to previous page
!Similar to previous page
!SMTP + Authentication
!SMTP + Authentication
!SMTP + POP before Authentication
!SMTP + POP before Authentication
|-style="background:#f0f0f0"
|-style=&quot;background:#f0f0f0&quot;
|[sendmail]||[sendmail]||[sendmail]
|[sendmail]||[sendmail]||[sendmail]
|-style="background:#f0f0f0"
|-style=&quot;background:#f0f0f0&quot;
|smtp_server='''smtp.xip.com'''||smtp_server='''smtp.xip.com'''||smtp_server='''smtp.xip.com'''
|smtp_server='''smtp.xip.com'''||smtp_server='''smtp.xip.com'''||smtp_server='''smtp.xip.com'''
|-style="background:#f0f0f0"
|-style=&quot;background:#f0f0f0&quot;
|smtp_port=25||smtp_port=25||smtp_port=25
|smtp_port=25||smtp_port=25||smtp_port=25
|-style="background:#f0f0f0"
|-style=&quot;background:#f0f0f0&quot;
|default_domain='''xip.com'''||default_domain='''xip.com'''||default_domain='''xip.com'''
|default_domain='''xip.com'''||default_domain='''xip.com'''||default_domain='''xip.com'''
|-style="background:#f0f0f0"
|-style=&quot;background:#f0f0f0&quot;
|;error_logfile=error.log||;error_logfile=error.log||;error_logfile=error.log
|;error_logfile=error.log||;error_logfile=error.log||;error_logfile=error.log
|-style="background:#f0f0f0"
|-style=&quot;background:#f0f0f0&quot;
|;debug_logfile=debug.log||;debug_logfile=debug.log||;debug_logfile=debug.log
|;debug_logfile=debug.log||;debug_logfile=debug.log||;debug_logfile=debug.log
|-style="background:#f0f0f0"
|-style=&quot;background:#f0f0f0&quot;
|;auth_username=||auth_username='''fred123@xip.com'''||;auth_username=
|;auth_username=||auth_username='''fred123@xip.com'''||;auth_username=
|-style="background:#f0f0f0"
|-style=&quot;background:#f0f0f0&quot;
|;auth_password=||auth_password='''me456'''||;auth_password=
|;auth_password=||auth_password='''me456'''||;auth_password=
|-style="background:#f0f0f0"
|-style=&quot;background:#f0f0f0&quot;
|;pop3_server=||;pop3_server=||pop3_server='''pop.xip.com'''
|;pop3_server=||;pop3_server=||pop3_server='''pop.xip.com'''
|-style="background:#f0f0f0"
|-style=&quot;background:#f0f0f0&quot;
|;pop3_username=||;pop3_username=||pop3_username=fred123@xip.com
|;pop3_username=||;pop3_username=||pop3_username=fred123@xip.com
|-style="background:#f0f0f0"
|-style=&quot;background:#f0f0f0&quot;
|;pop3_password= ||;pop3_password=||pop3_password=me456
|;pop3_password= ||;pop3_password=||pop3_password=me456
|-style="background:#f0f0f0"
|-style=&quot;background:#f0f0f0&quot;
|force_sender='''fred123@xip.com'''||force_sender='''fred123@xip.com'''||force_sender='''fred123@xip.com'''
|force_sender='''fred123@xip.com'''||force_sender='''fred123@xip.com'''||force_sender='''fred123@xip.com'''
|-style="background:#f0f0f0"
|-style=&quot;background:#f0f0f0&quot;
|;hostname=||;hostname=||;hostname=
|;hostname=||;hostname=||;hostname=
|}
|}
Line 217: Line 218:
'''''Test1'':'''
'''''Test1'':'''


Start Uniform Server and type the following into your browser address bar: '''<nowiki>http://localhost/mail.html</nowiki>'''
Start Uniform Server and type the following into your browser address bar: '''&lt;nowiki&gt;http://localhost/mail.html&lt;/nowiki&gt;'''


There is no need to enter any data into the text boxes. Just click on '''Send''' and you will receive this message:
There is no need to enter any data into the text boxes. Just click on '''Send''' and you will receive this message:
Line 230: Line 231:
To check whether 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.
To check whether 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 (<nowiki>http://localhost/mail.html</nowiki>). This time you will need to fill in the text boxes.
Run the test page (&lt;nowiki&gt;http://localhost/mail.html&lt;/nowiki&gt;). This time you will need to fill in the text boxes.
Confirm that the emails are received. That completes the tests.
Confirm that the emails are received. That completes the tests.



Revision as of 01:06, 24 November 2010

This Page Is Currently Under Construction And Will Be Available Shortly, Please Visit Reserve Copy Page

<span id="top"></span> <div style="padding:0;margin:0; border-bottom:3px inset #000000">

MPG UniCenter

PHP mail function | Installing Fake Sendmail for Windows

</div>

Uniform Server 3.5-Apollo.

Note: Uniform Server 5-Nano has msmtp mail client integrated. This is a ready alternative to “fake sendmail”.

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 to work with your host's SMTP server. However it fails if your host requires authentication. Fake sendmail for Windows to the rescue.

Unix users take all this stuff for granted; it's there and they just send emails. When they try to set sendmail "-t" on Windows, it's 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

Background

I like pictures because it helps with the thought processes. Take the PHP mail function; it has no preconceived idea what OS it's running on. The one thing it knows is that 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, it knocks on the php.ini door, checks that the door number, SMTP, smtp_port and sendmail_from are all filled in correctly and dumps the data. After getting a receipt, it proceeds on its merry way.

Next day, it 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; data it's found is taken, a receipt issued and 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]<br> <nowiki>;</nowiki> For Win32 only.<br> SMTP = localhost<br> smtp_port = 25

<nowiki>;</nowiki> For Win32 only.<br> sendmail_from = me@localhost.com

<nowiki>;</nowiki>For&nbsp;Unix&nbsp;only. You may supply arguments as well (default: ;"sendmail -t -i").<br> <nowiki>;</nowiki>sendmail_path = "/usr/bin/sendmail.exe -t"

<nowiki>;</nowiki>&nbsp;Force&nbsp;the&nbsp;addition&nbsp;of&nbsp;the&nbsp;specified&nbsp;parameters&nbsp;to&nbsp;be&nbsp;passed&nbsp;as&nbsp;extra&nbsp;parameters<br> <nowiki>;</nowiki> to the sendmail binary. These parameters will always replace the value of<br> <nowiki>;</nowiki> the 5th parameter to mail(), even in safe mode.<br> <nowiki>;</nowiki> mail.force_extra_paramaters =

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 that 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}

OR

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.

It's this option we use for linking Fake sendmail

Top

Pre-Installation

&nbsp;1&nbsp; A) Download the latest version of Fake sendmail for Windows the current version is (23 Apr 24, 2008) Save the file to a temporary folder for example c:\sendmail_temp.
&nbsp;2 B) Extract the file to the current folder (right click on sendmail.zip and select Extract All... click Next and Next again) this creates a new folder named sendmail.
&nbsp;3 C) Copy the folder sendmail and all its content from c:\sendmail_temp to the UniServer folder *Uniform Server\udrive\usr\local
&nbsp;4 D) If you wish to save space delete the source folder
&nbsp; <br>

Note 1: Contents of folder *Uniform Server\udrive\usr\local\sendmail

  • license.txt
  • ReadMe.html
  • sendmail.exe
  • sendmail.ini


Note 2: php.ini needs to be changed so it links to the executable sendmail.exe see next section.

Top

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 and search for this section <nowiki>[</nowiki>mail function<nowiki>]</nowiki> (starts around line 612)

php.ini section [mail function] Comments

[mail function]<br> <nowiki>;</nowiki> For Win32 only.<br> <nowiki>;</nowiki>SMTP = localhost<br> <nowiki>;</nowiki>smtp_port = 25

<nowiki>;</nowiki> For Win32 only.<br> ;sendmail_from = me@localhost.com

<nowiki>;</nowiki>For&nbsp;Unix&nbsp;only. You may supply arguments as well (default: ;"sendmail -t -i").<br> sendmail_path = "/usr/local/sendmail/sendmail.exe -t"


<nowiki>;</nowiki>&nbsp;Force&nbsp;the&nbsp;addition&nbsp;of&nbsp;the&nbsp;specified&nbsp;parameters&nbsp;to&nbsp;be&nbsp;passed&nbsp;as&nbsp;extra&nbsp;parameters<br> <nowiki>;</nowiki> to the sendmail binary. These parameters will always replace the value of<br> <nowiki>;</nowiki> the 5th parameter to mail(), even in safe mode.<br> <nowiki>;</nowiki> mail.force_extra_paramaters =

  1. Comment out the Win32 lines as shown by adding a ";" to the beginning of each line.<br><br>
  2. Enable the sendmail_path by removing the ";" at the begining of the line.<br><br>
  3. Replace the path:<br>/usr/bin/sendmail.exe -t<br>&nbsp;&nbsp;with<br>/usr/local/sendmail/sendmail.exe as shown.

Top

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).

Top

Test Solution 2

Test1:

Start Uniform Server and type the following into your browser address bar: <nowiki>http://localhost/mail.html</nowiki>

There is no need to enter any data into the text boxes. Just click on Send and 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 if you received the message.

Test 2:

To check whether 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 (<nowiki>http://localhost/mail.html</nowiki>). This time you will need to fill in the text boxes. Confirm that the emails are received. That completes the tests.

Top

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 if either resolves the problem or points to where the problem is:

  1. You need to be connected to the Internet (via your ISP) before running your PHP program.
  2. 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)
  3. Make sure your firewall or antivirus program is not blocking php.exe Internet access (port25).
  4. 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.

Top

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? It's worth a look, covered in this new project. One minor drawback: it's not a portable solution.

Top


Ric