CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
HTML Mail

 



darian
Deleted

Apr 7, 2000, 4:22 AM

Post #1 of 5 (734 views)
HTML Mail Can't Post

Ok with the code below I am trying to send a page via email. Only when I get it in my email (yahoo mail) it just shows the code. Anyone know what I am doing wrong? If I can figure this out then I can not only finish this program but have another to send out html newsletters.

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

open(FILE, "$db_site_path") or die("$!");
@lines = <FILE>;
close(FILE);
open(MAIL, "|$mailprog -t") or die("$!");
print MAIL "To: $toname <$toemail>\n";
print MAIL "From: $fromname <$fromemail>\n";
print MAIL "Subject: $subject\n\n";
print MAIL "Content-Type: text/html\n";
print MAIL "@lines";
close(MAIL);</pre><HR></BLOCKQUOTE>

Here's the output minus the header.

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">quote:</font><HR><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>The Perl Learning Group - Free scripts written in Perl</title>


<link rel=stylesheet type="text/css" href="images/tplg.css">
</head>
<body background="images/background.jpg" bgproperties="FIXED">

<table border=0 width="780" class="table">
<tr>
<td colspan="2" align="center" valign="top"
height="120"><center><img src="images/tplg-logo.gif" width=302 height=82 border=0
alt=""></center></td>
</tr>
<tr>
<td valign="top" align="left" width="225">
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0>
<TR>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=16 HEIGHT=1></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=8 HEIGHT=1></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=5 HEIGHT=1></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=75 HEIGHT=1></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=1></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=13 HEIGHT=1></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=5 HEIGHT=1></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=11 HEIGHT=1></TD>
</TR>
<TR>
<TD COLSPAN=8>
<IMG SRC="images/tplg-nav_01.gif" WIDTH=134 HEIGHT=25></TD>
</TR>
<TR>
<TD COLSPAN=2 ROWSPAN=2>
<IMG SRC="images/tplg-nav_02.gif" WIDTH=24 HEIGHT=54></TD>
<TD COLSPAN=3>
<A HREF="http://server30.hypermart.net/tplg/index.htm"
ONMOUSEOVER="window.status='Click here to go back to our home
page.'; return true;"
ONMOUSEOUT="window.status=''; return true;">
<IMG SRC="images/home.gif" WIDTH=81 HEIGHT=31 BORDER=0 ALT="Click
here to go back to our home page."></A></TD>
<TD COLSPAN=3 ROWSPAN=2>
<IMG SRC="images/tplg-nav_04.gif" WIDTH=29 HEIGHT=54></TD>
</TR>
<TR>
<TD COLSPAN=3>
<IMG SRC="images/tplg-nav_05.gif" WIDTH=81 HEIGHT=23></TD>
</TR>
<TR>
<TD ROWSPAN=8>
<IMG SRC="images/tplg-nav_06.gif" WIDTH=16 HEIGHT=205></TD>
<TD COLSPAN=5>
<A HREF="http://server30.hypermart.net/tplg/scripts.htm"
ONMOUSEOVER="window.status='Click here to see our scripts and
code.'; return true;"
ONMOUSEOUT="window.status=''; return true;">
<IMG SRC="images/scripts.gif" WIDTH=102 HEIGHT=29 BORDER=0
ALT="Click here to see our scripts and code."></A></TD>
<TD COLSPAN=2 ROWSPAN=2>
<IMG SRC="images/tplg-nav_08.gif" WIDTH=16 HEIGHT=53></TD>
</TR>
<TR>
<TD COLSPAN=5>
<IMG SRC="images/tplg-nav_09.gif" WIDTH=102 HEIGHT=24></TD>
</TR>
<TR>
<TD COLSPAN=6>
<A HREF="http://server30.hypermart.net/tplg/members/members.pl"
ONMOUSEOVER="window.status='Click here to meet the authors of
this site and our many fine scripts.'; return true;"
ONMOUSEOUT="window.status=''; return true;">
<IMG SRC="images/authors.gif" WIDTH=107 HEIGHT=27 BORDER=0
ALT="Click here to meet the authors of this site and our many fine
scripts."></A></TD>
<TD ROWSPAN=6>
<IMG SRC="images/tplg-nav_11.gif" WIDTH=11 HEIGHT=152></TD>
</TR>
<TR>
<TD COLSPAN=6>
<IMG SRC="images/tplg-nav_12.gif" WIDTH=107 HEIGHT=19></TD>
</TR>
<TR>
<TD COLSPAN=6>
<A HREF="http://server30.hypermart.net/tplg/contact.htm"
ONMOUSEOVER="window.status='Click here to contact one of our
members.'; return true;"
ONMOUSEOUT="window.status=''; return true;">
<IMG SRC="images/contact.gif" WIDTH=107 HEIGHT=30 BORDER=0
ALT="Click here to contact one of our members."></A></TD>
</TR>
<TR>
<TD COLSPAN=6>
<IMG SRC="images/tplg-nav_14.gif" WIDTH=107 HEIGHT=21></TD>
</TR>
<TR>
<TD COLSPAN=2 ROWSPAN=2>
<IMG SRC="images/tplg-nav_15.gif" WIDTH=13 HEIGHT=55></TD>
<TD>
<A HREF="http://server30.hypermart.net/tplg/links.htm"
ONMOUSEOVER="window.status='Click here to visit our supports
sites as well as some recommended sites.'; return true;"
ONMOUSEOUT="window.status=''; return true;">
<IMG SRC="images/links.gif" WIDTH=75 HEIGHT=27 BORDER=0 ALT="Click
here to visit our supports sites as well as some recommended
sites."></A></TD>
<TD COLSPAN=3 ROWSPAN=2>
<IMG SRC="images/tplg-nav_17.gif" WIDTH=19 HEIGHT=55></TD>
</TR>
<TR>
<TD>
<IMG SRC="images/tplg-nav_18.gif" WIDTH=75 HEIGHT=28></TD>
</TR>
</TABLE>
</td>
<td valign="top" align="left" width="530">
Welcome to "The Perl Learning
Group" website. Our goal as a group is to learn to program in Perl
and share what we learn
with others. This way maybe we can keep others from learning the
hard was as we are.
<P>
All of our code here is free to
use as long as you keep all copyright material in tact. If you use a
small piece of code please
make sure you give credit to the author of that code. Other then
that you may use what you
will.
<P>
Think you can write that piece of code better? Then
by all means let us know how. We are here to learn. All you have to
do is go to our
<a href="server30.hypermart.net/tplg/contact.htm">Contact</a> page
and fill in the form with your code. Please comment
every bit you can so we can tell what it is your doing. You will be
given full credit for the
code if it is your original code.
</td>
</tr>
<tr>
<td colspan=2 align="center">
<!-- Begin ListBot Code -->
<form method="post"
action="http://www.listbot.com/cgi-bin/subscriber">
<table border=0><tr><td colspan=2>
Join our mailing list!<br>
Enter your email address below,<br>
then click the 'Join List' button:<br>
</td></tr><tr><td>
<input type=text name="e_mail">
<input type=hidden name="list_id" value="tplg">
<input type=hidden name="Act" value="subscribe_list">
</td><td>
<input type=image src="http://www.listbot.com/subscribe_button.gif"
border=0 width=88 height=31 alt="Click here to join our mailing list!">
</td></tr><tr><td colspan=2>
<font size=1 face="arial"><a href="http://www.listbot.com/"
target="_top">Powered by ListBot</a></font><br>
</td></tr></table>
</form>
<!-- End ListBot Code -->
</td>
</tr>

<tr><td colspan=2 align=center><!--#echo
banner=""--></td></tr>
</table>



</body>
</html><HR></BLOCKQUOTE>


Cure
User

Apr 7, 2000, 5:05 PM

Post #2 of 5 (734 views)
Re: HTML Mail [In reply to] Can't Post

Hi

Its not working becuase of this line in your script-> print MAIL "Content-Type: text/html\n";

you need 2 new-line-characters for a http header.

so change that line to print MAIL "Content-Type: text/html\n\n";

Cure


darian
Deleted

Apr 7, 2000, 7:07 PM

Post #3 of 5 (734 views)
Re: HTML Mail [In reply to] Can't Post

Thanks Cure. That worked for some of the email programs. Will have to work on Yahoo! Mail though. It still shows the code not the page. Might just add a section in to detect if the domain is Yahoo and just send the link instead. Thanks again.


Cure
User

Apr 7, 2000, 7:55 PM

Post #4 of 5 (734 views)
Re: HTML Mail [In reply to] Can't Post

Hi

I figured it out.


open(FILE, "$db_site_path") or die("$!");
@lines = <FILE>;
close(FILE);

$toname='you@jon.net';
$fromname='me@yahoo.com';
open(MAIL, "|$sendmail -t") or die("$!");
print MAIL <<"END_OF_MAIL";
To: $toname
From: $fromname
Subject: perl
Content-Type: text/html

@lines
END_OF_MAIL
close(MAIL);


Cure



[This message has been edited by Cure (edited 04-07-2000).]


darian
Deleted

Apr 7, 2000, 10:01 PM

Post #5 of 5 (734 views)
Re: HTML Mail [In reply to] Can't Post

Ok solved it. Here is how.

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

open(FILE, "$db_site_path") or die("$!");
@lines = <FILE>;
close(FILE);
open(MAIL, "|$mailprog -t") or die("$!");
print MAIL "To: $toname <$toemail>\n";
print MAIL "From: $fromname <$fromemail>\n";
print MAIL "Subject: $subject\n";
print MAIL "Content-Type: text/html\n\n";
print MAIL qq~
@lines
~;

close(MAIL);</pre><HR></BLOCKQUOTE>

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives