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

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
Mail a story...



Mar 24, 2000, 9:50 AM

Post #1 of 4 (2269 views)
Mail a story... Can't Post

I see them everywhere.

The script that will let users "email this story to a friend" when they are surfing around.

Where the heck can I get one of those!!!!????

I've looked everywhere!


Mar 24, 2000, 12:49 PM

Post #2 of 4 (2269 views)
Re: Mail a story... [In reply to] Can't Post

I would be very interesting in seeing the script as well.




Mar 28, 2000, 4:35 AM

Post #3 of 4 (2269 views)
Re: Mail a story... [In reply to] Can't Post

Ok here is something I threw together that might lead you in the right direction.

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

use CGI qw(:cgi);
use CGI::Carp qw(fatalsToBrowser);
$in = new CGI;

$subject = 'Check this out!'; #What you want to put in the subject line.
$file = '/path/to/the/files/'; #path to where the text files are.
$url = 'http://url/to/the/files/'; #url to the directory where the text files are.
$link = 1; #1 to just send a link, 0 to send the file.
$return = 'http://url/back/to/your/page/';

$file.= $in->param('file');
$toname = $in->param('toname');
$toemail = $in->param('toemail');
$fromname = $in->param('fromname');
$fromemail = $in->param('fromemail');

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 "This mail was sent to you because, $toname, though you might like it.\n";
print MAIL "This mail was sent to using WEBMailer v1.0 created by Stanley Glass Jr\n";
print MAIL "of <a href=>Glass Images</a>.\n";
print MAIL "======================================================================\n\n";
if($link) {
print MAIL "Click on the link below or type the url into your browser to see this\n";
print MAIL "great page.\n\n"
print MAIL "$url\n";
else {
open(FILE, "$file") or die("$!");
while (<FILE> ) {
print MAIL "$!";

print "Location: $return \n\n";</pre><HR></BLOCKQUOTE>

Now you just have to add a few lines to your page where you want to have the form.

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

<form action=send.cgi method=post>
<input type="hidden" name="file" value="myfile.txt">
Name:<input type="text" name="toname"><br>
Email:<input type="text" name="toemail"><br>
Name:<input type="text" name="fromname"><br>
Email:<input type="text" name="fromemail"><br>
<input type="submit" value="Send">

You can go more extravagent but hey I just threw this one together. Havn't tested it yet either. Hope this helps you. Smile


Mar 28, 2000, 4:59 AM

Post #4 of 4 (2269 views)
Re: Mail a story... [In reply to] Can't Post


Thanks for the help and the script. Unfortunately, it would require me to put the form fields on every story or create a separate page for every story to email.

What I'm looking for specifically is to have one page with a form that automatically detects the page being recommended as in the following scenario:

User recommends a page by clicking on a button labeled "Recommend this page!."

The user is then redirected to a form where he/she fills out the appropriate fields (from, to, email, etc) but the form automatically knows which page the user was referring to.

I think this would require two scripts instad of just one:

1. the script that tells the form page what URL is being recommended.

2. a simple form script that will gather all information and process it.

Thanks anyways. Sorry that I couldn't use it...



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

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