Email notification attachment



  • Hello. I am having trouble to succed sending notification email with a small .csv file attached.

    This is what I am trying:

    
    #!/usr/local/bin/php -f
    require_once("auth.inc");
    require_once("config.inc");
    require_once("globals.inc");
    require_once("notices.inc");
    
    //SUBJECT
    $subject = "Test email with attachment";
    $attachment = file_get_contents("attachment.csv");
    //define the body of the message
    ?>
    //DEFINE MIME-TYPE AND HOW TO TREAT IT
    Content-type: text/csv; name=attachment.csv
    Content-disposition: attachment
    
    echo $attachment;
    $message = ob_get_clean();
    //send the e-mail
    send_smtp_message($message, $subject, $header);
    ?>
    
    

    The simpliest solution would be that "send_smtp_message" function would dispose another parameter like "$attachment", but it hasn't got that parameter field.

    So, is there anyway to achieve this?

    As you can see in the code, I am trying to specify that the variable "message" must be treated as an attachment, with no success.

    Any suggestions?


Log in to reply