Send the email as attachmnet using the mail() function

Send the email as attachmnet using the mail() function

/*  This function send the CSV order as an attachment */

function sendMailAsAttachment( $file, $path ) {
    
    $emailData = pepareEmail();
    $attachContent = pepareAttachment( $file , $path );
    $message = $emailData['message'].$attachContent;
    $ok = @mail($emailData['to'], $emailData['subject'], $message, $emailData['headers']); 
    if ($ok) { 
            echo "<p>mail sent to $to!</p>"; 
    } else { 
            echo "<p>mail could not be sent!</p>"; 
    } 
}

Share this Tutorial