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: Beginner:
Mail a story...

 



cbeaudry
Deleted

Mar 24, 2000, 9:50 AM

Post #1 of 4 (1095 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!


waherne
Novice

Mar 24, 2000, 12:49 PM

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

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

Regards,

Willie


darian
Deleted

Mar 28, 2000, 4:35 AM

Post #3 of 4 (1095 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>

#!/usr/local/bin/perl
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=http://www.glass-images.com>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 "$!";
}
}
close(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">
TO:<br>
Name:<input type="text" name="toname"><br>
Email:<input type="text" name="toemail"><br>
From:<br>
Name:<input type="text" name="fromname"><br>
Email:<input type="text" name="fromemail"><br>
<input type="submit" value="Send">
</form></pre><HR></BLOCKQUOTE>

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


cbeaudry
Deleted

Mar 28, 2000, 4:59 AM

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

Darian,

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...

Charles.

 
 


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

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