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

Well, here goes:
I'm trying to send a link from my script to sendmail, which in turn gets sent along to several email addresses. I'm guaranteed the same email client (netscape 4.76) for all my recipients, since this is just for work. I'm trying to embed the links in the good old fashioned way:
open(MAIL, '|/usr/lib/sendmail -t') or die "cannot fork sendmail: $!"; print MAIL "<a href=\"http://blah.com/script.cgi?approval=yes\">Click +here for YES</a> \n"; print MAIL "<a href=\"http://blah.com/script.cgi?approval=no\">Click h +ere for NO</a> \n";
...but the links show up exactly as they are typed above... and none of my users want to see all those lovely variables I'm passing, it'll just confuse them =/

So, what am I missing? I tried to include a "content type=text/html" line, but the links still printed out the long way. Can someone direct me to a sendmail reference, or share their own experience? Google is failing me in my searches so far... :(

Replies are listed 'Best First'.
Re: Sendmail & HTML
by suaveant (Parson) on Oct 05, 2001 at 20:36 UTC
    I have not used it myself, but I believe (looking at the docs) Mime::Lite allows you to send HTML mail

                    - Ant
                    - Some of my best work - Fish Dinner

Re: Sendmail & HTML
by kjherron (Pilgrim) on Oct 05, 2001 at 20:40 UTC
    You need to format your message following the MIME standard with a content type of text/html. I generally use the MIME::Lite module for something like this. It's pretty easy to use, and gives good results.
Re: Sendmail & HTML
by projekt21 (Friar) on Oct 08, 2001 at 17:29 UTC

    if not using one of those excellent MIME::* modules you could do something like the following to set a correct content-type for your mail:

    my $mailfrom = 'someone@somewhere.com'; my $mailcommand = "/usr/lib/sendmail -f\"$mailfrom\" -O\"NoRecipientAc +tion=add-to\" -t "; my $to = '...' # recipient goes here open MAIL, "| $mailcommand $to" or die "$0: Cannot execute command: $! +\n"; print MAIL <<EOT; To: $to MIME-Version: 1.0 Content-Type: text/html Content-Transfer-Encoding: 8Bit Subject: Some subject here ... your text ... EOT close MAIL;

    The relevant thing is that "Content-Type" line, give it a try...

    alex pleiner <alex@zeitform.de>
    zeitform Internet Dienste

      works Great!
Re: Sendmail & HTML
by Chady (Priest) on Oct 05, 2001 at 20:38 UTC