server_name can use PHP's own DNS parsing function,
The following is a core demonstration, Winnt,mail server is imail,php3.0.6
Need to modify Php3.ini to open the IMAP module, on Linux to compile PHP--with-imap
function Send_email ($to, $from, $subject, $message) {
Global $SERVER _name;
$fp = Fsockopen ($SERVER _name, 25);
if ($fp) {
echo "Connected";
Set_socket_blocking ($fp, false);
$output =fgets ($FP, 2500);
Echo $output;
if (! Ereg ("^220", $output)) {
Exit ();
} else {
echo "Talking";
Set_socket_blocking ($fp, true);
Fputs ($fp, "HELO $from _domain");
$output = Fgets ($fp, 2000);
Echo $output;
Fputs ($fp, "MAIL from: < $from >");
$output = Fgets ($fp, 2000);
Echo $output;
Fputs ($fp, "RCPT to: < $to >");
$output = Fgets ($fp, 2000);
Echo $output;
Fputs ($fp, "DATA");
Fputs ($FP, "to: $to");
Fputs ($FP, "From: $from");
Fputs ($FP, "Subject: $subject");
Fputs ($fp, "$message.");
Fputs ($fp, "QUIT");
}
}
Fclose ($FP);
}
$SERVER _name= "127.0.0.1";
$from _domain= "WS";
$to = "daiger@xifeng.com";
$from = "wangsu@xifeng.com";
$subject = "Test SMTP through PHP Chinese";
$message = "Send email via PHP SMTP connectionsnnnothing HAPPENESN Chinese
Chinese Chinese ";
Send_email ($to, $from, $subject, $message);
echo "OK lah";
?>
http://www.bkjia.com/PHPjc/532246.html www.bkjia.com true http://www.bkjia.com/PHPjc/532246.html techarticle server_name can use PHP own DNS resolution function, the following is the core demonstration, Winnt,mail server is imail,php3.0.6 need to modify Php3.ini open IMAP module, on Linux to compile PHP-- With-imap ...