I have a legacy app that needs to change. it is written in perl and uses send::mail to send mails to users. Previously we sent links in the email message body but now they want pdf attachments instead. The PDF's are generated on another server using php.
the workflow would be
- create the email body
- get the pdf from another server via a URL
- add the pdf as an attachment to the email
- send it.
I can use
LWP::Simple;
unless (defined ($content = get $URL)) {
die "could not get $URL\n";
}
to get the contents of the URL but I can't figure out how to use that var as an attachment in sendmail. current sendmail code is:
my %maildata = (
To => $to,
From => 'OurSite - Billing <bil...@ourSite.com>',
Bcc => 'sentb...@ourSite.com',
Subject => $subject{$message} || 'ourSite invoice',
Message => $body
);
sendmail(%maildata) || print STDERR $Mail::Sendmail::error;
I know I could set the content-type and the attachment: filename but that assumes storing the returned URL prior to attempting to send and I wasn't intending to do that.