Page 1 of 1

SMTP Mail in PHP/Linux

Posted: Mon Apr 07, 2003 7:56 am
by kattasrinivas
Dear All,
I Have an Requirement where i need to pass the mail server name dynamically for php mail, I know it is possible but don't know exactly how it works.
Iam working with php on Linux, Here is a simple Code Iam using for mail

*****************************
$to = "kattasrinivas@etisbew.com";
$subject = "Test";
$message ='Test';

$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: kattasrinivas@etisbew.com\r\n";

if(mail($to, $subject, $message,$headers)) {
echo "Mail Sent";
} else {
echo "Mail Not Sent" ;
}

***************************************
In the above Program I need to pass the mail server name dynamically, By default the mail server is considered as localhost

Any help in thsi regard is highly appreciated

Posted: Mon Apr 07, 2003 8:51 am
by volka
http://www.php.net/manual/en/ref.mail.php
on non-win32-systems php uses the injection part of your MTA and the configuration for that is PHP_INI_SYSTEM so your php-script cannot change it. You cannot setup the local MTA to send the mails to another server?

Or....

Posted: Tue Apr 08, 2003 1:25 am
by llimllib
Or, a possibly more elegant solution is to use the PEAR SMTP module. While not documented on their website, it is in the process of becoming a full package. Check it out here. Sample applications are included, and the source is very well documented.