kjg has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to use the Windmail header 'Attach' to add an attachment to an email that the my Perl Script is generating. Here are the relevant code snippets:
use Win32::ODBC; use CGI qw(:standard); use CGI::Carp qw/fatalsToBrowser/; $mailsubject = "Subject: ".$Form{'subject'}; $attachment = "Attach: ".$Form{'attachment'}; open MAIL, "|c:/windmail/windmail -t"; print MAIL "To:$Email\@ybs.co.uk\n"; print MAIL "From:Internal_Comms\@ybs.co.uk\n"; print MAIL "Subject:".$mailsubject." \n\n"; print MAIL "Attach:".$attachment."\n\n"; print MAIL "\n\n"; print MAIL $mailtext; close MAIL;
The variables are being read from a web-form, but essentially are just text:
$email = 'me'
$mailsubject = 'Any text'
$attachment = 'T:\anything.pdf'
$mailtext = 'some text'
What it actually sends is this:
To: me From: Internal_Comms Subject: Any text Message body: T:\Anything.pdf Some text
When the email arrives in my inbox, it has the little attachment icon against it, but when I open the email there actually is no attachment. What gives?

Please note I cannot use MIME::Lite or some such, it's Windmail or bust for me! :-(

Replies are listed 'Best First'.
Re: How do I get Windmail to send an email attachment
by Anonymous Monk on Apr 04, 2008 at 14:15 UTC
    RTFM, you havet too many \n\n
      Thanks. I've tided the script up to:
      open MAIL, "|c:/windmail/windmail -t"; print MAIL "To:$Email\@ybs.co.uk\n"; print MAIL "From:Internal_Comms\@ybs.co.uk\n"; print MAIL "Subject:".$mailsubject." \n"; print MAIL "Attach:".$attachment."\n\n"; print MAIL $mailtext; close MAIL;
      but I'm now getting:
      To: me From: Internal_Comms Subject: Any text Message body: Some text
      Once again, the email looks like it has an attachment in my inbox, but there is no attachment when I actually read the email.
      Somethings still not right, plainly!
        check the logs?
Re: How do I get Windmail to send an email attachment
by jepri (Parson) on Apr 05, 2008 at 12:58 UTC
    Hmmm, the documentation for windmail shows the attachment path in quotes. I'd start by making your example look exactly like the example in the manual, and then asking the windmail developers for help. Perl seems to be doing its job correctly (the mail gets sent), so it looks to be a problem with the way windmail is reading your message.