Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

PHP's mail() function is not usable in Shared-Hosting environments. 
Here is how to use SMTP for mailing with PHP: 

First, one needs Pear::Mail (see Pear.php.net). 

Next, in safemode open_basedir must includes /usr/share/php (with Debian's Pear::Mail package). 

Last not least the PHP code: 

include("Mail.php");

# $params["host"] - The server to connect. Default is localhost

$params["host"]="localhost";
# $params["port"] - The port to connect. Default is 25 # $params["auth"] - Whether or not to use SMTP authentication. Default is FALSE # $params["username"] - The username to use for SMTP authentication. # $params["password"] - The password to use for SMTP authentication. # $params["persist"] - Indicates whether or not the SMTP connection # should persist over multiple calls to the send() method. $recipients = array('To' => 'johndoe@foo.com'); $headers['From'] = 'johndoe@foo.com'; $headers['To'] = 'johndoe@foo.com'; $headers['Subject'] = "Foo topic"; $mail_object =& Mail::factory('smtp', $params); $mail_object->send($recipients, $headers, $message);

From: IBCL BLog.
Originally posted: 2006-12-20

  • No labels