Send attachment email form submission php

This tutorial explains how to send attachment email form submission php. The function accepts the form data and the upload file on form submissions and send the email using php.

Please refer the tutorial explains how to upload file as email attachment and send all files in a folder as email attachment php.

function sendMailAsAttachment( $filename, $fileorgname, $formData ) {
    
    $emailData = prepareEmail( $formData );
    $attachContent = prepareAttachment( $filename,$fileorgname );
    $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