当前位置:Gxlcms >
PHP教程 >
发附件有关问题,mb_send_mail不可以,mail可以,为啥
发附件有关问题,mb_send_mail不可以,mail可以,为啥
时间:2021-07-01 10:21:17
帮助过:2人阅读
发附件问题,mb_send_mail不可以,mail可以,为啥?
很着急啊,
求解。
谢谢先
以下是我的程序:
$from .= " <[email protected]> ";
$to .= " <[email protected]> ";
$subject = "添付ファイルテスト ";
$body = "添付ファイルテスト正文 ";
$filename = "/work/cgi-bin/prs/test.txt ";
$att_files = "/work/cgi-bin/prs/テストファイル.txt ";
//$mine = "js ";
//send_mail2($to, $subject, $text_body, $headers, $html_body= " ", $att_names= " ", $att_files= " ", $file_types= " ");
/*
if ($filename){
($attach = file_get_contents($filename)) Or die( "Open Error: $filename ");
$filename = basename($filename);
$ret = Attach_Mail($from, $to, $subject, $body, $filename, $attach, $mine);
}else{
}
*/
$ret = send_mail($to, $from, $subject, $body, $cc = null, $bcc = null, $filename);
//echo $ret;
function send_mail($to, $from, $subject, $body, $cc = null, $bcc = null, $attachment = null)
{
if ($to != " " && isset( $to ) ) {
$to =str_replace( " " , " " , $to ) ;
$to =str_replace( "\t " , ", " , $to ) ;
}
if ($cc != " " && isset( $cc ) ) {
$cc =str_replace( " " , " " , $cc ) ;
$cc =str_replace( "\t " , ", " , $cc ) ;
}
if ($bcc != " " && isset( $bcc ) ) {
$bcc =str_replace( " " , " " , $bcc ) ;
$bcc =str_replace( "\t " , ", " , $bcc ) ;
}
// 念の為、言語と文字コードの設定
$body = "BCC:$bcc\r\n$body\r\n ";
$body = "CC:$cc\r\n$body\r\n ";
$to_tmp = join( "\r\n ",explode( ", ",$to));
$body = "TO:$to_tmp\r\n$body\r\n ";
mb_language( "Japanese ");
mb_internal_encoding( "EUC-JP ");
mb_detect_order( "ASCII, JIS, UTF-8, EUC-JP, SJIS ");
// From を変換
//$FromName = mb_encode_mimeheader(mb_convert_encoding($FromName, 'JIS ', 'auto '));
//$header .= 'From: '.$FromName. ' < '.$FromMail. '> '. "\r\n ";
$to = "[email protected] ";