PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Mail » Mail » Bug #4705

smtp.php script should default to the server's SMTP setting in php.ini

Details

Submitted2005-06-29 17:15 UTC
Fromdang dot nguyen at docusign dot com
StatusWont fix
PackageMail
PHP Version5.0.4
OSWindows XP Pro
Roadmaps(Not assigned)

Comments

[2005-06-29 17:15 UTC] dang dot nguyen at docusign dot com

Description:
------------
The smtp server parameter is currently set to "localhost" by default. This should be set to whatever is set in php.ini if not specified in a PHP script. If the host parameter is not set and no smtp server exists on localhost, the script will fail to send email.

Reproduce code:
---------------
// this will fail if no smtp server exists on localhost
$mail =& Mail::factory('smtp');
$mail->send($recipients, $headers, $body);

// workaround to get the host parameter from php.ini
$params['host'] = ini_get('SMTP');

if(isset($recipients) && isset($headers) && isset($body)) {
$mail =& Mail::factory('smtp', $params);
$sent = $mail->send($recipients, $headers, $body);
}

Expected result:
----------------
Mail::factory should default to the SMTP parameter set in php.ini instead of localhost.

Actual result:
--------------
Mail doesn't get sent if smtp server doesn't exist on localhost.

[2005-06-29 18:55 UTC] dang dot nguyen at docusign dot com

Defaulting to localhost makes the script less portable (works only in Unix where smtp is commonly installed). However, even in Unix installations, smtp is not installed. Therefore, in either environment it could fail, except more commonly the failure will occur on a Windows server. Otherwise, every script that used to work in Unix/Linux would have to be updated when brought into a Windows environment (and more so if the smtp hostname changes). If the SMTP parameter is already set in php.ini, why not use it?