I've got some php code which export mysql database to a .xls file. I can download immediately when I run the code. However, can I use php to send this file to an admin email account every time when below code generates a new .xls file?
Thanks.
<?php
    require_once('connect.php');
    $group = 1;//$_GET['group'];
    $export = mysql_query ("SELECT * FROM relationship WHERE group_id = $group");
    $fields = mysql_num_fields ( $export );
    for ( $i = 0; $i < $fields; $i++ )
    {
        $header .= mysql_field_name( $export , $i ) . "\t";
    }
    while( $row = mysql_fetch_row( $export ) )
    {
        $line = '';
        foreach( $row as $value )
        {                                            
            if ( ( !isset( $value ) ) || ( $value == "" ) )
            {
                $value = "\t";
            }
            else
            {
                $value = str_replace( '"' , '""' , $value );
                $value = '"' . $value . '"' . "\t";
            }
            $line .= $value;
        }
        $data .= trim( $line ) . "\n";
    }
    $data = str_replace( "\r" , "" , $data );
    if ( $data == "" )
    {
        $data = "\n(0) Records Found!\n";                        
    }
    header("Content-type: application/octet-stream");
    header("Content-Disposition: attachment; filename=your_desired_name.xls");
    header("Pragma: no-cache");
    header("Expires: 0");
    print "$header\n$data";
    mysql_close($my_connection);
    ?>
