Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

E-mail from perl with html links

Status
Not open for further replies.

youthman

Programmer
Apr 28, 2004
49
US
Is there something special that I have to do to make links appear as links in an e-mail sent from perl? My e-mail system is set up to display html. When I preview the results of a perl script in my browser, it all appears correctly, but when I e-mail that same output to myself, the links do not display. They show as:
<a href . . . . .> text here </a>
instead of the link on "text here" to the page!

Any ideas why that might be?

The Youthman
 
well, first I think you have to push out the content type on the email as <Content-Type: text/html> to get it to read html tags in the header of the email. Then I think you just write it out normally


___________________________________
[morse]--... ...--[/morse], Eric.
 
Where would I put that? I have tried it before the body, and before it all, and neither one works! here is my code for this section:

Code:
 open(MAIL, "| $sendmail") or die "Cant open Sendmail";

print MAIL <<EOF;
<Content-Type: text\/html>
From: $from
Reply-to: $from
Errors-to: $from
Sender: $from
To: $email
Subject: $subject

$ppage

EOF
close MAIL;
 
Hi youthman,

the Content-type should be placed directly under the subject in the body of the email...

Code:
open(MAIL, "| $sendmail") or die "Cant open Sendmail";

print MAIL <<EOF;
From: $from
Reply-to: $from
Errors-to: $from
Sender: $from
To: $email
Subject: $subject
[COLOR=red]Content-Type: text/html\n\n[/color]

$ppage

EOF
close MAIL;

hopefully this should work for you
 
You could always just use Mime::Lite to make sure it's done correctly.

Doing a quick html e-mail test with Mime::Lite, I got this:
Code:
Content-Disposition: inline
Content-Length: 27
Content-Transfer-Encoding: binary
Content-Type: text/html
MIME-Version: 1.0
X-Mailer: MIME::Lite 3.01 (F2.71; A1.60; B2.12; Q2.03)
Date: Thu, 22 Jul 2004 17:40:34 UT
To: to@address.com
From: from@address.com
Subject: Test

<body>this is a test</body>
Try using those headers and see if it helps. Also, in the Mime::Lite doc, the html e-mail example has the html body tags in the body of the message, so make sure you're including those as well.

BTW, Mime::Lite sends messages via sendmail by default.
 
hi youthman,

to get HTML formatted email all you require is to place

Content-Type: text/html\n\n

directly after the Subject: line.

try the following:

Code:
open(MAIL, "| $sendmail") or die "Cant open Sendmail";

print MAIL <<EOF;
From: $from
Reply-to: $from
Errors-to: $from
Sender: $from
To: $email
Subject: $subject
Content-Type: text/html\n\n

<a href="[URL unfurl="true"]http://www.tek-tips.com/">Tek-Tips</a>[/URL]

EOF
close MAIL;

this should work...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top