美文网首页
Mail函数发送附件

Mail函数发送附件

作者: IARNO | 来源:发表于2018-11-28 11:06 被阅读0次
    <?php
    
            $from = "xxx@qq.com";
            $to = "xxx@163.com";
            $subject = "标题";
            $subject = "=?UTF-8?B?".base64_encode($subject)."?=";
            $path = "附件路径";
            $attach_filename = "附件名";
    
            $emailBody =  "请查看附件";
    
    # 然后我们要作为附件的HTML文件
            $attachment = file_get_contents($path);
    
            $boundary = uniqid("");
    
            $headers =  "From: $from
    To: $to
    Content-type: multipart/mixed; boundary=\"$boundary\"";
    
            $emailBody =  "--$boundary
    Content-type: text/plain; charset=utf-8
    Content-transfer-encoding: 8bit
    
    $emailBody
    
    --$boundary
    Content-type: text/html; name=$attach_filename
    Content-disposition: inline; filename=$attach_filename
    Content-transfer-encoding: 8bit
    
    $attachment
    
    --$boundary--";
    
            mail("xxx@qq.com", $subject, $emailBody, $headers);
    

    相关文章

      网友评论

          本文标题:Mail函数发送附件

          本文链接:https://www.haomeiwen.com/subject/gqlaqqtx.html