smtp_maliler.php \r\n", "250", "MAIL FROM: "), //6.RCPT TO 250 array("RCPT TO: ". $mailto ."\r\n", "250", "RCPT TO: "), //7.DATA Start 354 array("DATA\r\n", "354", "DATA Start: "), //8.0 From array("From: ". $smtp_from ."\r\n", "", ""), //8
\r\n", "250", "MAIL FROM: "),
//6.RCPT TO 250
array("RCPT TO: <". $mailto .">\r\n", "250", "RCPT TO: "),
//7.DATA Start 354
array("DATA\r\n", "354", "DATA Start: "),
//8.0 From
array("From: ". $smtp_from ."\r\n", "", ""),
//8.1 To
array("To: ". $mailto ."\r\n", "", ""),
//8.2 X-Mailer
array("X-Mailer: LANSEYUJIE WebMailer 1.0\r\n", "", ""),
//8.3 X-Priority
array("X-Priority: 1 (Highest)\r\n", "", ""),
//8.4 Subject
array("Subject: ". $subject ."\r\n", "", ""),
//8.5 Content-Type
array("Content-Type: text/html; charset=\"utf-8\"\r\n", "", ""),
//8.6 Content-Transfer-Encoding
array("Content-Transfer-Encoding: base64\r\n\r\n", "", ""),
//8.7 Base64 Encode Body
array(base64_encode($body) ."\r\n", "", ""),
//9.DATA End 250
array("\r\n.\r\n", "250", "DATA End: "),
//10.QUIT
array("QUIT\r\n", "221", "QUIT: ")
);
$info = '';
//fsockopen
if (1 == $smtp_openssl) {
$fp = @fsockopen('ssl://'. $smtp_host, $smtp_port);
}
else {
$fp = @fsockopen($smtp_host, $smtp_port);
}
if (!$fp) {
$info .= "FSOCKOPEN Error: Cannot conect to ". $smtp_host ."\r\n
";
}
//发送smtp数组中的命令/数据
foreach ($smtp as $request) {
//发送信息
@fputs($fp, $request[0]);
//如果需要接收服务器返回信息,则
if (1 == $smtp_debug && '' != $request[1]) {
//接收信息
$response = @fgets($fp, 128);
$info .= $request[2] . $response ."\r\n
";
}
}
//关闭连接
@fclose($fp);
return $info;
}
echo smtp_mailer('test@lanseyujie.com', 'Mailer Test', 'This is a test mail to verify the Mailer run or not!');
