Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Email notification attachment

    Scheduled Pinned Locked Moved General pfSense Questions
    1 Posts 1 Posters 653 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J Offline
      julero13
      last edited by

      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?

      1 Reply Last reply Reply Quote 0
      • First post
        Last post
      Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.