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

I'm trying to embed a hyperlink in the body of an email using Mail::Sendmail. Research has been done at http://cpan.uwinnipeg.ca/htdocs/Mail-Sendmail/Sendmail.html without success.
#!/usr/bin/perl -wT use strict; use CGI qw(:standard); # import most common gateway interface funct +ions use CGI::Carp qw(warningsToBrowser fatalsToBrowser); #cause all diagno +stics to be sent to browser use Mail::Sendmail; print header; print start_html("using Mail::Sendmail"); print "Thank you. Your email with hyperlink has been sent.\n"; my $recipient = "abc\@aol.com"; my $sender = "def\@aol.com"; my %mail = ( From => $sender, To => $recipient, Subject => "sending you mail" ); $mail{Message} = "Here is the hyperlink you requested.\n"; $mail{Message} .= ????? sendmail (%mail); print end_html;

Replies are listed 'Best First'.
Re: embedding hyperlink using Mail::Sendmail
by derby (Abbot) on Aug 26, 2005 at 01:04 UTC

    So what's the problem? Is the URL appearing in the email but not clickable or not appearing in the email? Most modern mail clients will turn a properly formed URL (http://www.foo.bar) into a clickable element.

    You may want to check into sending HTML mail (check out the Mail::Sendmail FAQ).

    -derby

      I'd highly suggest against HTML email -- for it to work consistently for everyone, you'd have to do a MIME alternative, with a plain text component ... so you have to generate two messages, and lots of other overhead.

      Odds are, most people's e-mail browsers are going to look for http urls (and many other of the more common protocols), and handle turning it into a link, if it makes sense for the mail client. If it doesn't, the user is going to be used to dealing with this sort of thing, and can deal with it on their own.

        I too would highly suggest against it but the OP was vague on what he was trying to do.

        Although I recommend against HTML email, I've been getting a *lot* of pressure from clients for HTML email. So I bite the bullet, get them to at least agree to an opt-out to plain text (or preferably an opt-in for html).

        Unfortunately there's not a lot of information about sending HTML email reliably. I would love to see a list of email clients that support/don't support HTML email (or more importantly to what degree they support HTML).

        Right now I use the following guidelines:

        • use MIME::Lite
        • set the Type and Encoding properly
        • use CSS inline (embedded breaks in most web mail clients as does import)
        • always have an opt-out (revert to plain text)

        Right now, some of the market surveys we've done show about a 60/40 love/hate relationship with HTML emails - I think if there was more standarization for email clients (both web and standalone), that number of haters would decrease significantly

        -derby