Alternative ways of sending message
The following ways of sending message from the php-scripts are spread nowadays:
- By means of calling mail function
- By means of calling sendmail
- With the help of sockets
- Using COM object
First three ways are implemented in the class PEAR::Mail. The copy of that class must be created by the means of static calling of the factory method. The first parameter of the method defines the way of the mail sending. It can take the following values: mail, sendmail, smtp. Second parameter is an array. Its content depends on the value of the first parameter.
- ‘mail’ value – sending by means of standard function calling. There are no additional parameters.
- ‘sendmail’ value – sending by means of sendmail calling. Additional parameters are accessible:
- sendmail_path – the way to program on the server
- sendmail_args – additional parameters for command line
- 'smtp' value – mail sending with the help of sockets. Additional parameters are accessible:
- host – IP address or domain name of the server with mail agent that can receive mail, for example localhost (for local server) or mxs.mail.com (for public server);
- port – port it has been launched at (as a rule 25)
- auth – logic value that points at necessity of SMPT authorization, default value – false;
- username – used only in the presence of authorization, login on the server
- password – used only in the presence of authorization, password on the server
Example of class PEAR::Mail using:
<?php
$mail =& Mail::factory("smtp", array("host" => "localhost", "port" => 25));
$mail->send("postmaster@localhost", $hdrs, $body);
?>



