procmail
[Top] [All Lists]

Re: Sending an html file in a procmail recipe

2003-01-12 11:35:34
On Sun, 12 Jan 2003, LuKreme wrote:

:0c
| (formail -r -A "Precedence: bulk" -A "X-Loop: kremels.loop" ; \
     echo "" ; cat $HOME/thefile.txt) | $SENDMAIL -t


All I get, of course, is the bare html in a text file.

Fine, I can add the Content-type header

It's important to remember that "Content-Type: ..." is only valid when it 
appears in conjunction with "MIME-Version: 1.0".  Some user agents will
honor it regardless, but the standards say the MIME-Version: field must
be present (and must contain "1.0" as the field body).

but is there anyway that I can setup thefile.txt itself to contain
everything it needs?

Put the necessary headers (content-type, mime-version, etc.) at the top
of the file and then:

TO=`formail -rx To:`

:0
* $ ? formail -A"To: $TO" < $HOME/thefile.txt | $SENDMAIL "$TO"
{
 LOG="Mailed thefile.txt to $TO
"
}

I prefer passing the address as an explicit argument rather than rely on
-t to parse it from the header, but if you're using Cc: or Bcc: fields in
thefile.txt then you should change the above to use the -t option.  The
LOG entry is just a bonus.

I would like thefile.txt to be self contained, so it was sent as a 
valid HTML message regardless of whether it was procmail or simply:

mail -s "thefile" user(_at_)domain(_dot_)tld < thefile.txt

You're not going to be able to pull that off, because "mail -s" will add a
blank line between the headers it generates and the contents of the file.
But you can use the same shape of formail command both in procmailrc and
at a shell prompt:

 formail -A"Subject: thefile" -A"To: user(_at_)domain(_dot_)tld" < thefile.txt |
  sendmail -t


_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>