Mutt for html body and multiple html & pdf attachments

Hi all:

Been racking my brain on this for the last couple of days and what has been most frustrating is that this is the last piece I need to complete a project.

There are numerous posts discussing mutt in this forum and others but I have been unable to find similar issues.

Running with RHEL 5.5, mutt 1.4.2.2i, perl 5.8.8

The issue is sending emails from command line using mutt. These emails can have 0 attachments to 5 attachments that can be a mix of html and/or pdf. Sending an email with html body/no attachments was simple;

system("/usr/bin/mutt -s \"Support\" -- \"$cust\" < $body");

Works, no problems.

When the -a options are included for the attachments I am still able to have the mail sent and it is received with an html body but the attachments become in line with the body making them unusable. If I add the

then the attachments are received fine but the body is plain text with all of the html markups in view.

I can add the

on the command line or in .muttrc, same effect. An example of the CLI;

system("/usr/bin/mutt -e \"my_hdr Content-Type:text/html\" -s \"Support\" @attach -- \"$cust\" < $body");

.

How can I do this? It seems like I need the

off for the body of the email and then to turn it on for the attachments.

I was using MIME::Lite in a perl-cgi script but when the pdf attachments wouldn't work I was able to track it down to the

. There are numerous problems with pdf attachments originating from perl-cgi using the MIME::Lite module, mainly they would arrive in a corrupted state and not properly decoded making them unusable. The html attachments were fine.

If at all possible I want to avoid having to install another package. My feeling is that I will encounter similar issues other clients like mpack. Plus they are not installed and there are many hoops to jump through to get them installed.

Many thanks!

You need to supply the content type like below, this is a simple example of how it works for me in a perl script:

$mail_type='set content_type="text/html"'

$child_pid = open( MUTT,"|mutt -e ${mail_type} -e ${replyto_name} -e ${replyto_email_address} " .
                        "-s ${subject} -a ${attachment} ${emailrecip}" );
if ( not defined( $child_pid  ) ) {
  print "**Error: Could not open pipe to mutt -- additional error text\n";
  writelog ("ERR Could not open pipe to mutt -- additional error text");
  return 1;
}
# The $message variable has the embedded html
print MUTT $message;
unless (close MUTT) {
  print "**Error: Could not close pipe to mutt -- additional error text\n";
  writelog ("ERR Could not close pipe to mutt -- additional error text");
  return 1;
}

hth