Difference between revisions of "5.3-Nano: msmtp"

Jump to navigation Jump to search
99 bytes added ,  23:18, 27 January 2010
Minor grammar and spelling changes
(New page: {{Nav 5.3-Nano}} '''Uniform Server and Msmtp an SMTP client''' It’s been a long time since I looked at SMTP clients. Generally most use the Windows registry however for portability that...)
 
(Minor grammar and spelling changes)
 
Line 1: Line 1:
{{Nav 5.3-Nano}}
{{Nav 5.3-Nano}}
'''Uniform Server and Msmtp an SMTP client'''
'''Uniform Server and Msmtp, an SMTP client'''


It’s been a long time since I looked at SMTP clients. Generally most use the Windows registry however for portability that’s a no go. I finally narrowed it down to '''msmtp''' its flexible, relative easy to set-up more importantly its portable.
It’s been a long time since I looked at SMTP clients. Generally most use the Windows registry, but for portability that’s a no go. I finally narrowed it down to '''msmtp'''. It's flexible, relative easy to set-up, and more importantly it's portable.


The above can be configured to use your ISP’s SMTP server however that again restricts portability. The answer is to create a free account at Google Mail ('''gmail''') and configure msmtp to use that.
While msmtp can be configured to use your ISP’s SMTP server, that again restricts portability. The answer is to create a free account at Google Mail ('''gmail''') or '''Hotmail''' and configure msmtp to use that.


This combination allows any PHP scripts to send e-mail to your gmail account transparently. MSMTP has been integrated into Uniform Server all you need to do is configure the account as explained below.  
This combination allows any PHP scripts to send e-mail to your gmail account transparently. MSMTP has been integrated into Uniform Server. All you need to do is configure the account as explained below.  


== Background ==
== Background ==
SMTP (simple mail transport protocol) was originally designed to be an open relay where an SMTP server would accept any e-mail for forwarding. This quickly became abused by spammers in retaliation ISP’s restricted open relaying. This means you cannot use the PHP function to directly send e-mail to a user. You either require your own mail server with all the complication that is associated with it or use your ISP’s SMTP server. In either situation you are restricted to a local server on a dedicated line.
SMTP (simple mail transport protocol) was originally designed to be an open relay where an SMTP server would accept any e-mail for forwarding. This quickly became abused by spammers. In retaliation, ISP’s restricted open relaying. This means you cannot use the PHP function to directly send e-mail to a user. You either require your own mail server with all the complication that is associated with it, or you use your ISP’s SMTP server. In either situation you are restricted to a local server on a dedicated line.


Free e-mail accounts such as Google Mail remove these chains by allowing you to relay through their servers. However you must login to their servers before this privilege is granted that’s the price you pay.
Free e-mail accounts such as Google Mail remove these chains by allowing you to relay through their servers. However you must login to their servers before this privilege is granted.  That’s the price you pay.


That said add the above solution to DtDNS and you have a real portable server.  
That said, add the above solution to DtDNS and you have a real portable server.  


'''''[[#top | Top]]'''''
'''''[[#top | Top]]'''''
Line 19: Line 19:
PHP uses the default account as set in configuration file UniServer\msmtp\'''msmtprc.ini'''
PHP uses the default account as set in configuration file UniServer\msmtp\'''msmtprc.ini'''


Before running any PHP scripts that send mail at least '''one account''' in this file must be configured and set as default.
Before running any PHP scripts that send mail, at least '''one account''' in this file must be configured and set as default.


The file contains three-example configurations that will suit most requirements.  
The file contains three example configurations that will suit most requirements.  


'''''[[#top | Top]]'''''
'''''[[#top | Top]]'''''
=== MyISP ===
=== MyISP ===
The first account, MyISP replaces the basic sendmail settings that would have been set in the php.ini file.
The first account, MyISP, replaces the basic sendmail settings that would have been set in the php.ini file.


It assumes your Internet service provider does not require you to authenticate. Hence all that is required is your ISP’s smtp server name and your email address.
It assumes your Internet service provider does not require you to authenticate. Hence all that is required is your ISP’s smtp server name and your email address.
Line 48: Line 48:
'''''Note'':''' Other accounts are ignored. PHP will use this account to send emails and your ISP will relay them to the appropriate address.
'''''Note'':''' Other accounts are ignored. PHP will use this account to send emails and your ISP will relay them to the appropriate address.


I mentioned above this account is restrictive because it ties you to your service provider hence is not portable. However it has one advantage requires minimum of configuration.
I mentioned above that this account is restrictive because it ties you to your service provider, so it is not portable. However it has one advantage which is it requires a minimum of configuration.


'''''[[#top | Top]]'''''
'''''[[#top | Top]]'''''


=== Hotmail ===
=== Hotmail ===
The second account, Hotmail is a free account that you need to create at the following address '''http//www.hotmail.com''' once signed up you will have an email address and password. These are required to configure your msmtp account.  
The second account, Hotmail, is a free account that you need to create at the following address '''http//www.hotmail.com''' once signed up you will have an email address and password. These are required to configure your msmtp account.  
{|
{|
|-
|-
Line 81: Line 81:
'''''[[#top | Top]]'''''
'''''[[#top | Top]]'''''
=== Gmail ===
=== Gmail ===
The third account, Gmail is a free account that you need to create at the following address '''http://mail.google.com/''' once signed up you will have an email address and password. These are required to configure your msmtp account.  
The third account, Gmail, is a free account that you need to create at the following address '''http://mail.google.com/''' once signed up you will have an email address and password. These are required to configure your msmtp account.  
{|
{|
|-
|-
Line 111: Line 111:


=== General Note ===
=== General Note ===
I would recommend you sign-up to the above free accounts and try each in tern (change default) to determine which best suits your requirements. You can create any number of accounts however make sure the account name is unique.
I would recommend you sign-up to the above free accounts and try each in turn (by changing the default) to determine which best suits your requirements. You can create any number of accounts, however make sure the account name is unique.


'''''[[#top | Top]]'''''
'''''[[#top | Top]]'''''
Line 186: Line 186:


== Integration ==
== Integration ==
You can skip this section however if you are interested in how msmtp integrates into Uniform Server’s architecture read on. This section is useful for users who wish to upgrade when a newer version of msmtp is released.
You can skip this section. However if you are interested in how msmtp integrates into Uniform Server’s architecture, read on. This section is useful for users who wish to upgrade when a newer version of msmtp is released.


'''''[[#top | Top]]'''''
'''''[[#top | Top]]'''''
Line 196: Line 196:
* To folder: UniServer\'''msmtp'''
* To folder: UniServer\'''msmtp'''


If you are upgrading that’s all there is to do.
If you are upgrading, that’s all there is to do.


'''''[[#top | Top]]'''''
'''''[[#top | Top]]'''''
=== How it is integrated ===
=== How it is integrated ===
There are three requirements for integration, inform PHP where to find the msmtp executable, inform msmtp where to find it’s configuration file. Finally inform msmtp where it’s log file is to be located.
There are three requirements for integration: inform PHP where to find the msmtp executable, inform msmtp where to find its configuration file, and finally inform msmtp where its log file is to be located.


The configuration file is located in folder UniServer\'''msmtp''' and named '''msmtprc.ini''' (could have been any other appropriate name) This configuration file contains a path to the log file it is specified as an absolute for example:
The configuration file is located in folder UniServer\'''msmtp''' and named '''msmtprc.ini''' (could have been any other appropriate name) This configuration file contains a path to the log file, specified as an absolute path. For example:


logfile "C:/some_folder/UniServer/msmtp/sendmail.log"
logfile "C:/some_folder/UniServer/msmtp/sendmail.log"


'''''Note'':''' When servers are moved this path is automatically updated.
'''''Note'':''' When servers are moved, this path is automatically updated.


A single line placed in php.ini configuration file caters for the first two requirements. Line has the following format:
A single line placed in php.ini configuration file caters to the first two requirements. Line has the following format:


sendmail_path = "C:/some_folder/UniServer/msmtp/msmtp.exe --file=C:/ some_folder/UniServer/msmtp/msmtprc.ini  -t"
sendmail_path = "C:/some_folder/UniServer/msmtp/msmtp.exe --file=C:/ some_folder/UniServer/msmtp/msmtprc.ini  -t"
    
    
'''''Note 1'':''' Absolute paths with forward slashes are used. The first part instructs PHP where to find the msmtp executable second part instructs msmtp where to find its configuration file.
'''''Note 1'':''' Absolute paths with forward slashes are used. The first part instructs PHP where to find the msmtp executable, and the second part instructs msmtp where to find its configuration file.


'''''Note 2'':''' When servers are moved line sendmail_path is automatically updated reflecting the new paths.   
'''''Note 2'':''' When servers are moved, line sendmail_path is automatically updated reflecting the new paths.   


There are three php.ini files (php.ini, php.ini_delvelopment_nano and php.ini_production_nano) that require modification, parts of the sendmail section are commented out and the above line added as shown below:  
There are three php.ini files (php.ini, php.ini_delvelopment_nano and php.ini_production_nano) that require modification, parts of the sendmail section are commented out and the above line added as shown below:  
Line 245: Line 245:
</pre>
</pre>
|}
|}
'''''Note'':''' File $usf_msmtp is defined in UniServer\unicon\main\includes\'''config.inc.php'''. A user may delete msmtp and use an alternative hence files existence is check first, this prevents error messages.
'''''Note'':''' File $usf_msmtp is defined in UniServer\unicon\main\includes\'''config.inc.php'''. A user may delete msmtp and use an alternative. So the file's existence is check first; this prevents error messages.


'''''[[#top | Top]]'''''
'''''[[#top | Top]]'''''


=== General note ===
=== General note ===
At first sight msmtp.exe looks large at 2.13 MB however it is self contained and compares favourably with alternatives such as fake send mail sendmail.exe 828 KB requires, libeay32.dll 1.06 MB and ssleay32.dll 208 KB  
At first sight, msmtp.exe looks large at 2.13 MB, however it is self contained and compares favourably with alternatives such as fake sendmail.  sendmail.exe (828 KB) requires libeay32.dll (1.06 MB) and ssleay32.dll (208 KB) (=2.10 MB).


'''''[[#top | Top]]'''''
'''''[[#top | Top]]'''''


== Summary ==
== Summary ==
For a home web server or small business server the above is a very good compromise.  
For a home web server or small business server, the above is a very good compromise.  


However for a portable server it is ideal, include this with DtDNS and you can have a portable server on-line within ten minutes with email capability.
However for a portable server it is ideal. Include this with DtDNS and you can have a portable server with email capability on-line within ten minutes.


'''''[[#top | Top]]'''''
'''''[[#top | Top]]'''''

Navigation menu