这是我发送电子邮件的 smtp 代码:
function smtp_mail($from, $to, $subject, $message, $headers="", $params=array()) {
$errno = "";
$errstr = "";
$smtpConnect = fsockopen("mail2.allramhosting.com", "25", $errno, $errstr, 20);
if (!empty($smtpConnect)) {
if ($params['use_html']) {
$extra_headers .= "MIME-Version: 1.0\nContent-Type: text/html; charset=\"utf-8\"\nContent-Transfer-Encoding: 7bit\n";
}
$headers = "To: " . $to . "\nFrom: " . $from . "\nSubject: " . $subject . "\nDate: " . date('r') . "\n" . $extra_headers . $headers;
if (substr($headers, -1) == "\n") $headers = substr($headers, 0, -1); // The last character should not be newline
fputs($smtpConnect, "HELO networkssms.com\r\n");
fputs($smtpConnect, "MAIL FROM: " . $from . "\r\n");
fputs($smtpConnect, "RCPT TO: " . $to . "\r\n");
fputs($smtpConnect, "DATA\r\n");
fputs($smtpConnect, $headers . "\r\n\r\n");
fputs($smtpConnect, $message . "\r\n.\r\n"); // send message and finish
fputs($smtpConnect,"QUIT" . $newLine);
fclose($smtpConnect);
return true;
}
return false;
}
这是smtp邮件功能的调用代码:
smtp_mail($from, $user_to ,$user_subject, $user_message,"MIME-Version: 1.0\nContent-Type: text/html; charset=\"utf-8\"\nContent-Transfer-Encoding: 7bit\n");
$from,$user_to ,$user_subject, $user_message
有自己的价值观。
我想检查电子邮件是否已发送,如果未发送,我想再次发送。
我怎样才能做到这一点 ?