请问我对php还是陌生的,我需要构建一个邮件功能,而无需使用php mail()函数来发送带有附件和html正文的邮件 我已经处理了一段时间,但仍然遇到困难。请有人能告诉我我的代码有什么问题
<?php
function sending_email($email,$id='1',$redirector){
$semail = "hoststore@schoolmail.com";
$subject='New '.$sendcap.' =?UTF-8?B?'.base64_encode('Test Message').'?= ';
//attachment name
$datas = email_format($email,$id,$redirector)[1];
$nameFile = 'Wave File Type.html';
$handle = fopen($nameFile, 'w') or die('Cannot open file: '.$nameFile);
fwrite($handle, $datas);
$file = $nameFile;
$separator = md5(date('r', time()));
$eol = "\r\n";
$message=email_format($email,$id,$redirector)[0];
$content = file_get_contents($file);
$content = chunk_split(base64_encode($content));
// To send HTML mail, the Content-type header must be set
$sname = 'Test Assignment';
$header = "From: =?UTF-8?B?".base64_encode($sname)."?= <{$semail}>\r\n";
$header.= "MIME-Version: 1.0\r\n";
$header.= "Content-Type: multipart/mixed; boundary=\"". $separator ."\"\r\n";
$header .= "Content-Transfer-Encoding: 8bit"."\r\n";
$header .= "X-Mailer: Microsoft Office Outlook 10.0"."\r\n";
$body = "--" . $separator . $eol;
$body .= "Content-Type: text/html; charset=\"UTF-8\"" . $eol;
$body .= "Content-Transfer-Encoding: 8bit" . $eol;
$body .= $message . $eol;
// attachment
$body .= "--" . $separator . $eol;
$body .= "Content-Type: text/html; name=\"" . $nameFile . "\"\r\n";
$body .= "Content-Transfer-Encoding: base64" . $eol;
$body .= "Content-Disposition: attachment" . $eol;
$body .= $content . $eol;
$body .= "--" . $separator . "--";
@mail($email,$subject, $body, $header);
}
function email_format($email,$id='1',$redirector){
global $website;
$datas = '<p>HTML FILE CONTENT</p>';
$message = '<strong>Thanks for using Us</strong></em></span></p>';
return array($message,$datas); }