Jeff O.
04-30-2004, 11:07 AM
I developed a PHP app that I want to send e-mails. I wrote the function below and it works perfectly. My question for you gurus is: Is there a better way of setting the e-mail server than the way I set it here, i.e. - via the ini_set(). I will be delivering this app to a couple of different clients, so my plan is to simply change the ini_set() line for each client's e-mail server.
Much appreciated! :)
<?php
///////////////////////////////////////////////////////////////////////////////////////////////
//
// Name: email_functions.php (Functions)
// Author: Jeff Ocheltree
// Date: 12/1/2003
// Purpose: PHP e-mail functions.
// Revisions:
//
///////////////////////////////////////////////////////////////////////////////////////////////
function send_email($to,$subject,$message,$header)
{
//I set the mail server here. This is a PHP ini file setting, but I set it here dynamically with ini_set(). The mail server setting may be an issue when porting the app to different servers, primarily because of firewall configurations.
ini_set("SMTP","mail.mycompany.com");
if (@mail($to,$subject,$message,$header)) {
//E-mail sent successfully.
return true;
}else{
//E-mail failure. Probably target domain not found.
return false;
}
}
?>
Much appreciated! :)
<?php
///////////////////////////////////////////////////////////////////////////////////////////////
//
// Name: email_functions.php (Functions)
// Author: Jeff Ocheltree
// Date: 12/1/2003
// Purpose: PHP e-mail functions.
// Revisions:
//
///////////////////////////////////////////////////////////////////////////////////////////////
function send_email($to,$subject,$message,$header)
{
//I set the mail server here. This is a PHP ini file setting, but I set it here dynamically with ini_set(). The mail server setting may be an issue when porting the app to different servers, primarily because of firewall configurations.
ini_set("SMTP","mail.mycompany.com");
if (@mail($to,$subject,$message,$header)) {
//E-mail sent successfully.
return true;
}else{
//E-mail failure. Probably target domain not found.
return false;
}
}
?>