send_mail() questions
Posted: Thu Apr 21, 2005 10:17 pm
Maybe some stupid questions but these are messing me. All know there's a send_mai() in php and say it's easy to use. But I can't find any documentation that explains FROM WHICH EMAIL ADDRESS the mail will be sent.
Say I have 3 email addresses (boss@any.com, sales@any.com and me@any.com), how do I know (or decide) which one to send a mail?
And how to test mail functions on localhost? When we install PHP using the binary package, they have us provide a email address, say to be used (me@localhost.com)
These are some codes I took from a site, anyone can explain them?
Thanks for any help!
Say I have 3 email addresses (boss@any.com, sales@any.com and me@any.com), how do I know (or decide) which one to send a mail?
And how to test mail functions on localhost? When we install PHP using the binary package, they have us provide a email address, say to be used (me@localhost.com)
These are some codes I took from a site, anyone can explain them?
Code: Select all
<?
function send_mail($to, $from, $subject, $body) {// is $from the address php wil use to send?
$path_to_sendmail = "/usr/sbin/sendmail";// for what? a CGI to send mail?
$fp = popen("$path_to_sendmail -t", "w");
$num = fputs($fp, "To: $to\n");
$num += fputs($fp, "From: $from\n");
$num += fputs($fp, "Subject: $subject\n\n");
$num += fputs($fp, "$body");
pclose($fp); if ($num>0) { return 1; } else { return 0; } }
?>Thanks for any help!