attach csv file on email sent from postgres I have the following code to send emails and wanted to see if it's possible to attach a csv file?
CREATE OR REPLACE FUNCTION public.send_email_html(text, text, text, text)
 RETURNS integer
 LANGUAGE plperlu
AS $function$
    use Net::SMTP;

    my ($recipientString, $sendFrom, $subject, $message) = @_;
    my @recipients = split /;/, $recipientString;
    my $smtp=Net::SMTP-&gt;new(&quot;localhost&quot;);
    
    $smtp-&gt;mail($sendFrom);
    foreach(@recipients)
    {
        $smtp-&gt;recipient($_);
    }
    $smtp-&gt;data();
    foreach(@recipients)
    {
        $smtp-&gt;datasend(&quot;To: $_\n&quot;);
    }
    
    $smtp-&gt;datasend(&quot;Subject: $subject\n&quot;);
    $smtp-&gt;datasend(&quot;Content-Type: text/html;\n&quot;);
    $smtp-&gt;datasend(&quot;$message\n&quot;);
    $smtp-&gt;quit();

    return 1;
$function$
;
Since you've already picked perl the easiest way might be to use MIME::Lite